filmov
tv
RHCE 8 - Ansible User Module

Показать описание
So lets take a look at creating and managing users in Ansible. In doing so we can investigate variables sourced from directories, group_vars/ and using the Ansible vault to encrypt sensitive data. We may also want to create more than one user account and we can do this using loops within our task. This will allow us to create the 4 users. In the same way we can delete the same users using a loop. We will also ensure to disable the gather_facts task which we don't need, saving valuable CPU time on our system. As this is helping you prepare for your RHCE in RHEL 8 as well as understanding Ansible, I encourage you to practice this on your own system.
---
- name: Create New Users
hosts: all
gather_facts: false
tasks:
- name: Create Users Task
user:
name: "{{ item }}"
state: present
password: "{{ default_user_password | password_hash('sha512', 'A512') }}"
shell: /bin/bash
groups: "{{ admin_group }}"
loop:
- bob
- wendy
- lofty
- dizzy
...
---
- name: Create New Users
hosts: all
gather_facts: false
tasks:
- name: Create Users Task
user:
name: "{{ item }}"
state: present
password: "{{ default_user_password | password_hash('sha512', 'A512') }}"
shell: /bin/bash
groups: "{{ admin_group }}"
loop:
- bob
- wendy
- lofty
- dizzy
...
Комментарии