Skip to main content

Ansible Tutorials for RHCE EX294 Certification Exam

Chapter #11: Managing Systems With Ansible

This is the eleventh chapter of RHCE Ansible EX 294 exam preparation series. Here, you'll learn about using Ansible modules to manage Linux systems.

So far, you have learned about all the core components of Ansible. Now it’s time to learn about the most common Ansible modules that are used for performing daily administrative tasks.

In this tutorial, you will learn how to manage users, groups, software and processes with Ansible. You will also learn how to configure networking and local storage on your Ansible managed systems.

Managing users and groups

You can use the following modules to manage users and groups in Ansible:

  • user: Manage user accounts and user attributes. For Windows targets, use the win_user module instead.
  • group: Manage presence of groups on a host. For Windows targets, use the win_group module instead.
  • pamd: Edit PAM service's type, control, module path and module arguments.
  • authorized_key: Copies SSH public key from Ansible control node to the target user .ssh/authorized_keys file in the managed node.
  • acl: Set and retrieve file ACL information.
  • selogin: Manages Linux user to SELinux user mapping.

You need to be aware that the authorized_key module doesn’t generate SSH keys; To generate, SSH keys, you can use the generate_ssh_key option with the user module.

Also, keep in mind that there is no sudo module in Ansible. You can use Jinja2 and other modules like lineinfile, blockinfile, replace, or copy to edit sudo configurations.

Now let’s create a playbook that uses some of the aforementioned modules to show you how you can manage users and groups in Ansible. But first, let’s create three new users (angela, tyrell, and darlene) on our control node.

Ahmed Alkabary
Website Regina,Canada