Ansible Lab - Quick Learn
Ansible Lab - Quick Learn
Ansible Lab - Quick Learn
Command Lab
In this lab, you set up and configure the Ansible Controller server for
managing remote hosts. You install the required packages on the
Controller server, create a user, and set up SSH private keys. Then
you test connecting to remote hosts. Finally, you run ad hoc
commands to manage the remote hosts.
Goals
Install Red Hat Ansible Engine
Create a user on the remote hosts
Test connectivity to the remote hosts
Explore ad hoc commands
1. Connect to Environment
1. Set some useful environment variables:
2. [laptop ]$ export GUID=<"GUID from email">
3. [laptop ]$ export MYKEY=<~/.ssh/your_key.pem>
[laptop ]$ export MYUSER=<username-company.com>
Example
[laptop ]$ export GUID=e4gh
[laptop ]$ export MYKEY=~/.ssh/psrivatkey
[laptop ]$ export MYUSER=psrivast-redhat.com
2. Configure Ansible
Controller
In this section, you set up and configure the bastion host as the
Ansible Controller server.
You create a devops user on the Ansible Controller and generate an
SSH key pair for the user. The devops user is used to run all of the
Ansible CLI commands to manage the remote hosts.
Sample Output
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Package ansible-2.6.2-1.el7.noarch already installed and latest
version
Nothing to do
The ansible package must be installed from a supported repository using yum.
Sample Output
Changing password for user devops.
passwd: all authentication tokens updated successfully.
Sample Output
Generating public/private rsa key pair.
Created directory '/home/devops/.ssh'.
Your identification has been saved in /home/devops/.ssh/id_rsa.
Your public key has been saved in /home/devops/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:kmAyJJMCordVF51xd4AmkgzDRYa8rcMUjStBHfL7Dr0
devops@bastion.${GUID}.example.opentlc.com
The key's randomart image is:
+---[RSA 2048]----+
|*...o+=X*+.o..o..|
|=+ .+B+= +.o. . |
|o + +..= . o |
| . *..+o. |
| . ++.S |
| ++ |
| ..o |
| o . |
| E |
+----[SHA256]-----+
Sample Output
total 8
-rw-------. 1 devops devops 1675 Aug 16 00:23 id_rsa
-rw-r--r--. 1 devops devops 421 Aug 16 00:23 id_rsa.pub
Sample Output
hosts (5):
frontend1.${GUID}.internal
support1.${GUID}.internal
app1.${GUID}.internal
app2.${GUID}.internal
appdb1.${GUID}.internal
Sample Output
app1.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
support1.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
app2.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
frontend1.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
appdb1.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
Sample Output
appdb1.${GUID}.internal | SUCCESS => {
"changed": true,
"comment": "",
"create_home": true,
"group": 1001,
"home": "/home/devops",
"name": "devops",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1001
}
frontend1.${GUID}.internal | SUCCESS => {
"changed": true,
"comment": "",
"create_home": true,
"group": 1001,
"home": "/home/devops",
"name": "devops",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1001
}
output omitted....
Sample Output
ssh-rsa AAAABLzz3......lxV1sZld0sGVP
devops@bastion.${GUID}.example.opentlc.com
3. Add the SSH key to the authorized keys for the devops user,
making sure to replace the value of the SSH public key with the
one that you just displayed:
[root@bastion ~]# ansible all -m authorized_key -a "user=devops
state=present key='ssh-rsa AAAAB......3lxV1sZld0sGVP
devops@bastion.${GUID}.example.opentlc.com'"
Sample Output
appdb1.${GUID}.internal | SUCCESS => {
"backup": "",
"changed": true,
"msg": "line added"
}
app1.${GUID}.internal | SUCCESS => {
"backup": "",
"changed": true,
"msg": "line added"
}
Output Omitted....
Sample Output
The authenticity of host 'app1.${GUID}.internal (<no hostip for
proxy command>)' can't be established.
ECDSA key fingerprint is
SHA256:VoJ8NXtSBgbB/YK59iA7yzop56MuGSavYg/0prLGEu4.
ECDSA key fingerprint is
MD5:ee:d9:66:8d:8f:f7:19:bf:9d:a5:79:c2:a9:dc:44:24.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'app1.${GUID}.internal' (ECDSA) to the
list of known hosts.
Last login: Thu Aug 16 00:54:17 2018
Sample Output
[root@app1 ~]#
9. Repeat the previous two steps for all of the other remote hosts.
4. Explore Ad Hoc
Commands
After you have successfully configured the Ansible Controller and
remote hosts, you can run Ansible ad hoc commands and
playbooks as the devops user from bastion without being prompted for
the password.
In this section, you explore ad hoc commands to manage remote
hosts.
You configure ansible.cfg and the static inventory needed to complete
this lab. You use-u to specify the devops user and --private-key to
specify the private key.
1. Verify connectivity to the remote hosts:
[devops@bastion ~]$ ansible frontends -m ping
Sample Output
frontend1.${GUID}.internal | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Warning:
Permanently added 'frontend1.${GUID}.example.opentlc.com' (ECDSA)
to the list of known hosts.\r\nno such identity:
/home/devops/.ssh/${GUID}key.pem: No such file or
directory\r\nPermission denied (publickey,gssapi-keyex,gssapi-
with-mic).\r\n",
"unreachable": true
}
Sample Output
[defaults]
inventory = /home/devops/ansible_implementation/hosts
host_key_checking = False
Sample Output
frontend1.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
Sample Output
app1.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
support1.${GUID}.internal | SUCCESS => {
"changed": false,
"ping": "pong"
}
Output Omitted....
Sample Output
[WARNING]: provided hosts list is empty, only localhost is
available. Note that the implicit localhost does not match 'all'
Sample Output
app1.${GUID}.internal | SUCCESS | rc=0 >>
23. Create the /etc/motd file on all of the hosts, but this time,
escalate the root user’s privileges using -b or --become:
[devops@bastion ansible_implementation]$ ansible all -m copy -a
'content="Managed by Ansible\n" dest=/etc/motd' -u devops --
private-key=~/.ssh/id_rsa --become
Sample Output
app1.${GUID}.internal | SUCCESS => {
"changed": true,
"checksum": "4458b979ede3c332f8f2128385df4ba305e58c27",
"dest": "/etc/motd",
"gid": 0,
"group": "root",
"md5sum": "65a4290ee5559756ad04e558b0e0c4e3",
"mode": "0644",
"owner": "root",
"secontext": "system_u:object_r:etc_t:s0",
"size": 19,
"src": "/home/devops/.ansible/tmp/ansible-tmp-1534387341.14-
178337610750037/source",
"state": "file",
"uid": 0
}
Output Omitted...
Sample Output
app1.${GUID}.internal | SUCCESS | rc=0 >>
Managed by Ansible
Example
[laptop ]$ export GUID=e4gh
[laptop ]$ export MYKEY=~/.ssh/psrivatkey
[laptop ]$ export MYUSER=psrivast-redhat.com
Sample Output
frontend1.${GUID}.internal
appdb1.${GUID}.internal
app1.${GUID}.internal
support1.${GUID}.internal
app2.${GUID}.internal
[lb]
frontend1.${GUID}.internal
[webservers]
app1.${GUID}.internal
app2.${GUID}.internal
[db]
appdb1.${GUID}.internal
Sample Output
playbook: check_webserver.yml
Sample Output
PLAY [webservers]
*****************************************************************
*****************************************************
PLAY RECAP
*****************************************************************
************************************************************
app1.${GUID}.internal : ok=2 changed=0
unreachable=0 failed=0
app2.${GUID}.internal : ok=2 changed=0
unreachable=0 failed=0
Sample Output
PLAY [webservers]
*****************************************************************
*****************************************************
TASK [Gathering Facts]
*****************************************************************
************************************************
ok: [app1.${GUID}.internal]
ok: [app2.${GUID}.internal]
PLAY RECAP
*****************************************************************
************************************************************
app1.${GUID}.internal : ok=2 changed=0
unreachable=0 failed=0
app2.${GUID}.internal : ok=2 changed=0
unreachable=0 failed=0
o Note that the play in the playbook is running on app1 and app2 as
both of the systems are member of the webservers host group.
Sample Output
Output Omitted....
[webservers]
app1.${GUID}.internal
app2.${GUID}.internal
[db]
appdb1.${GUID}.internal
[webservers:vars]
ansible_user = devops
ansible_ssh_private_key_file = /home/devops/.ssh/id_rsa
Sample Output
PLAY [webservers]
*****************************************************************
*****************************************************
PLAY RECAP
*****************************************************************
************************************************************
app1.${GUID}.internal : ok=2 changed=0
unreachable=0 failed=0
app2.${GUID}.internal : ok=2 changed=0
unreachable=0 failed=0
Sample Output
PLAY [webservers]
*****************************************************************
*****************************************************
PLAY RECAP
*****************************************************************
************************************************************
app1.${GUID}.internal : ok=4 changed=3
unreachable=0 failed=0
app2.${GUID}.internal : ok=4 changed=3
unreachable=0 failed=0
21. Verify that you are able to access the web page on
the app1 host:
[devops@bastion ansible_implementation]$ curl
http://app1.${GUID}.internal
Sample Output
Hoorraaayyy!!! My first playbook ran successfully
22. Verify that you are able to access the web page on
the app2 host:
[devops@bastion ansible_implementation]$ curl
http://app2.${GUID}.internal
Sample Output
Hoorraaayyy!!! My first playbook ran successfully
7. Clean Up Environment
1. Run a playbook to perform the cleanup:
[devops@bastion ansible_implementation]$ cd
~/ansible_implementation_grading/
[devops@bastion ansible_implementation_grading]$ export
GUID=`hostname | awk -F"." '{print $2}'`
[devops@bastion ansible_implementation_grading]$ ansible-playbook
lab-3.1-cleanup.yml -e GUID=${GUID}
Facts Lab
In this lab, you gather Ansible facts from a managed host. Then you
create custom facts and use them in a playbook. Finally, you install
packages based on those custom facts.
Goals
Work with facts
Create custom facts
Verify custom facts
Use facts to configure the web server hosts
1. Connect to Environment
1. Set some useful environment variables:
2. [laptop ]$ export GUID=<"GUID from email">
3. [laptop ]$ export MYKEY=<~/.ssh/your_key.pem>
[laptop ]$ export MYUSER=<username-company.com>
Example
[laptop ]$ export GUID=e4gh
[laptop ]$ export MYKEY=~/.ssh/psrivatkey
[laptop ]$ export MYUSER=psrivast-redhat.com
4. Connect to the bastion host with your OPENTLC ID and private
key:
[laptop ]$ ssh -i ${MYKEY}
${MYUSER}@bastion.${GUID}.example.opentlc.com
2. Gather Facts
In this section, you gather Ansible facts from a managed host and
examine them.
1. Using the Ansible setup module, run an ad hoc command to
retrieve the facts for all of the servers in the db group:
2. [user-company.com@bastion ~]$ sudo -i
3. [root@bastion ~]# su - devops
4. [devops@bastion ~]$ export GUID=`hostname | awk -F"." '{print
$2}'`
5. [devops@bastion ~]$ cd ~/ansible_implementation
[devops@bastion ansible_implementation]$ ansible db -m setup
Sample Output
appdb1.${GUID}.internal | SUCCESS => {
"ansible_facts": {
"ansible_all_ipv4_addresses": [
"192.199.0.176"
],
"ansible_all_ipv6_addresses": [
"fe80::97:55ff:feb1:12b8"
],
"ansible_apparmor": {
"status": "disabled"
},
"ansible_architecture": "x86_64",
"ansible_bios_date": "08/24/2006",
"ansible_bios_version": "4.2.amazon",
"ansible_cmdline": {
"BOOT_IMAGE": "/boot/vmlinuz-3.10.0-693.el7.x86_64",
"LANG": "en_US.UTF-8",
"console": "tty0",
"crashkernel": "auto",
"net.ifnames": "0",
Output Omitted...
o The output displays all of the facts gathered for appdb1 server in
JSON format.
6. Review the variables displayed.
7. Filter the facts matching the ansible_user expression and append a
wildcard to match all of the facts starting with ansible_user:
[devops@bastion ansible_implementation]$ ansible db -m setup -a
'filter=ansible_user*'
Sample Output
appdb1.${GUID}.internal | SUCCESS => {
"ansible_facts": {
"ansible_user_dir": "/home/devops",
"ansible_user_gecos": "",
"ansible_user_gid": 1001,
"ansible_user_id": "devops",
"ansible_user_shell": "/bin/bash",
"ansible_user_uid": 1001,
"ansible_userspace_architecture": "x86_64",
"ansible_userspace_bits": "64"
},
"changed": false
}
Sample Output
app2.${GUID}.internal | SUCCESS => {
"ansible_facts": {
"ansible_local": {
"custom": {
"general": {
"package": "httpd",
"service": "httpd",
"state": "started"
}
}
}
},
"changed": false
}
app1.${GUID}.internal | SUCCESS => {
"ansible_facts": {
"ansible_local": {
"custom": {
"general": {
"package": "httpd",
"service": "httpd",
"state": "started"
}
}
}
},
"changed": false
}
Sample Output
PLAY [Install Apache and starts the service]
*****************************************************************
**************************
PLAY RECAP
*****************************************************************
************************************************************
app1.${GUID}.internal : ok=3 changed=2
unreachable=0 failed=0
app2.${GUID}.internal : ok=3 changed=2
unreachable=0 failed=0
Sample Output
app2.${GUID}.internal | SUCCESS | rc=0 >>
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service;
disabled; vendor preset: disabled)
Active: active (running) since Fri 2018-08-17 11:41:58 UTC;
2min 19s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 2536 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current
traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─2536 /usr/sbin/httpd -DFOREGROUND
├─2537 /usr/sbin/httpd -DFOREGROUND
├─2538 /usr/sbin/httpd -DFOREGROUND
├─2539 /usr/sbin/httpd -DFOREGROUND
├─2540 /usr/sbin/httpd -DFOREGROUND
└─2541 /usr/sbin/httpd -DFOREGROUND
6. Clean Up Environment
1. Run a playbook to perform the cleanup:
2. [devops@bastion ansible_implementation]$ cd
~/ansible_implementation_grading/
3. [devops@bastion ansible_implementation_grading]$ export
GUID=`hostname | awk -F"." '{print $2}'`
[devops@bastion ansible_implementation_grading]$ ansible-playbook
lab-3.2-cleanup.yml -e GUID=${GUID}
Variables Lab
In this lab, you define and use variables in a playbook. You create a
playbook that installs the Apache web server and opens the ports
for the service to be reachable. The playbook queries the web
server to ensure that it is up and running.
Goals
Define variables in a playbook and create tasks that include
defined variables
Gather facts from a host and create tasks that use the gathered
facts
Define variables and tasks in separate files and use the files in
playbooks
1. Connect to Environment
1. Set some useful environment variables:
2. [laptop ]$ export GUID=<"GUID from email">
3. [laptop ]$ export MYKEY=<~/.ssh/your_key.pem>
[laptop ]$ export MYUSER=<username-company.com>
Example
[laptop ]$ export GUID=e4gh
[laptop ]$ export MYKEY=~/.ssh/psrivatkey
[laptop ]$ export MYUSER=psrivast-redhat.com
2. Create the tasks block and add a first task, which uses
the yum module to install the required packages.
3. Add two more tasks to start and enable
the httpd and firewalld services.
4. Add a task that creates content in /var/www/html/index.html.
5. Add a task that uses the firewalld module to add a rule for the
web service.
Playbook Solution
[devops@bastion ansible_implementation]$ cat << EOF >
variable_test.yml
- name: Install Apache and start the service
hosts: webservers
become: yes
vars:
web_pkg: httpd
firewall_pkg: firewalld
web_service: httpd
firewall_service: firewalld
python_pkg: python-httplib2
rule: http
tasks:
- name: Install the required packages
yum:
name:
- "{{ web_pkg }}"
- "{{ firewall_pkg }}"
- "{{ python_pkg }}"
state: latest
- name: Start and enable the {{ firewall_service }} service
service:
name: "{{ firewall_service }}"
enabled: true
state: started
EOF
Sample Output
playbook: variable_test.yml
4. Run Playbooks
In this section, you run the variable_test.yml playbook to set up the
web services ofapp1 and app2. Then you run
the webserver_smoketest.yml smoke-test playbook to verify that the web
services are running on the correct hosts.
1. Run the variable_test.yml playbook:
[devops@bastion ansible_implementation]$ ansible-playbook
variable_test.yml
Sample Output
PLAY [Install Apache and start the service]
*****************************************************************
**************************************************
PLAY RECAP
*****************************************************************
*****************************************************************
******************
app1.${GUID}.internal : ok=6 changed=5
unreachable=0 failed=0
app2.${GUID}.internal : ok=6 changed=5
unreachable=0 failed=0
Sample Output
PLAY [Verify the Apache service]
*****************************************************************
*************************************************************
PLAY RECAP
*****************************************************************
*****************************************************************
******************
localhost : ok=2 changed=0 unreachable=0
failed=0
Sample Output
TASK [Fail if 'Example web content' is not in the page content]
*****************************************************************
******************************
skipping: [localhost]
PLAY RECAP
*****************************************************************
*****************************************************************
******************
localhost : ok=7 changed=4 unreachable=0
failed=0
6. Clean Up Environment
1. Undo the changes made to webservers:
[devops@bastion ansible_implementation_grading]$ ansible-playbook
lab-4.1-cleanup.yml -e GUID=${GUID}
1. Connect to Environment
1. Set some useful environment variables:
2. [laptop ]$ export GUID=<"GUID from email">
3. [laptop ]$ export MYKEY=<~/.ssh/your_key.pem>
[laptop ]$ export MYUSER=<username-company.com>
Example
[laptop ]$ export GUID=e4gh
[laptop ]$ export MYKEY=~/.ssh/psrivatkey
[laptop ]$ export MYUSER=psrivast-redhat.com
service: httpd
svc_state: started
Sample Output
playbook: main_playbook.yml
[devops@bastion ansible_implementation]$
5. Run Playbook
1. Run the playbook and examine the output:
[devops@bastion ansible_implementation]$ ansible-playbook
main_playbook.yml
Sample Output
PLAY [webservers]
*****************************************************************
*****************************************************************
***********
PLAY RECAP
*****************************************************************
*****************************************************************
******************
app1.${GUID}.internal : ok=8 changed=3
unreachable=0 failed=0
app2.${GUID}.internal : ok=8 changed=3
unreachable=0 failed=0
Sample Output
ip-192-199-0-96.ec2.internal has been customized using Ansible on
the 2018-08-21
Sample Output
ip-192-199-0-96.ec2.internal has been customized using Ansible on
the 2018-08-21
o You see this output because the index.html file was created.
7. Clean Up Environment
1. Run a playbook to clean up the lab environment:
2. [devops@bastion ansible_implementation_grading]$ export
GUID=`hostname | awk -F"." '{print $2}'`
[devops@bastion ansible_implementation_grading]$ ansible-playbook
lab-4.2-cleanup.yml -e GUID=${GUID}
Roles Lab
In this lab, you create Ansible roles that use variables, files,
templates, tasks, and handlers to deploy a network service and
enable a working firewall. You then use Ansible Galaxy to initialize a
new Ansible role, and download and install an existing role.
Goals
Create Ansible roles to deploy a network service and enable a
working firewall
Use Ansible Galaxy to initialize, download, and install roles
1. Connect to Environment
1. Set some useful environment variables:
2. [laptop ]$ export GUID=<"GUID from email">
3. [laptop ]$ export MYKEY=<~/.ssh/your_key.pem>
[laptop ]$ export MYUSER=<username-company.com>
Example
[laptop ]$ export GUID=e4gh
[laptop ]$ export MYKEY=~/.ssh/psrivatkey
[laptop ]$ export MYUSER=psrivast-redhat.com
2. Create Roles
In this section, you create roles to deploy the web application. You
create a role to set up the Apache web server. Then you create a
role to install mariadb and use a database backup file to populate the
database. Lastly, you create a role for setting up a HAProxy load
balancer for high availability for your web application.
9. Create the vars/main.yml file under the app-tier role directory that
contains definitions for all of the variables defined in tasks.
10. Create the file handlers/main.yml under the app-tier role directory
that contains a handler to restart services if needed.
Playbook Solution
[devops@bastion ansible_implementation]$ mkdir roles/
[devops@bastion ansible_implementation]$ ansible-galaxy init
roles/app-tier
[devops@bastion ansible_implementation]$ cat << EOF > roles/app-
tier/tasks/main.yml
---
# tasks file for roles/app-tier
# Installation of packages based on inventory groupss
- name: Install Firewalld
yum:
name: firewalld
state: latest
EOF
- name: restart_httpd
service:
name: "{{ httpd_srv }}"
state: restarted
EOF
db:
user: root
database: userdb
password: redhat
httpd_pkg:
- httpd
- php
- php-mysql
httpd_srv: httpd
db_srv: mariadb
EOF
o password: redhat
o database: userdb
Playbook Solution
[devops@bastion ansible_implementation]$ ansible-galaxy init
roles/db-tier
[devops@bastion ansible_implementation]$ cp ~/roles-setup-
files/userdb.backup roles/db-tier/files/
[devops@bastion ansible_implementation]$ cat << EOF > roles/db-
tier/tasks/main.yml
---
# tasks file for roles/db-tier
- name: Install mysql
yum:
name: "{{ item }}"
state: latest
loop:
- "{{ db_pkg }}"
Playbook Solution
[devops@bastion ansible_implementation]$ cat << EOF > webapp-
main.yml
- hosts: webservers
become: yes
roles:
- app-tier
- hosts: db
become: yes
roles:
- db-tier
- hosts: lb
become: yes
roles:
- lb-tier
EOF
Sample Output
Output Ommitted....
PLAY RECAP
*****************************************************************
*****************************************************************
******************
app1.3fd5.internal : ok=10 changed=5 unreachable=0
failed=0
app2.3fd5.internal : ok=10 changed=5 unreachable=0
failed=0
appdb1.3fd5.internal : ok=9 changed=4 unreachable=0
failed=0
frontend1.3fd5.internal : ok=9 changed=4 unreachable=0
failed=0
4. Test Playbook
1. Open a web browser window and enter
thehttp://frontend1.${GUID}.example.opentlc.com/ URL.
2. When the web page prompts you for the username, enter kiosk.
Sample Output
kiosk redhat /bin/bash /home/kiosk
Sample Output
Output Omitted...
Output Omitted...
1. Connect to Environment
1. Set some useful environment variables:
2. [laptop ]$ export GUID=<"GUID from email">
3. [laptop ]$ export MYKEY=<~/.ssh/your_key.pem>
[laptop ]$ export MYUSER=<username-company.com>
Example
[laptop ]$ export GUID=e4gh
[laptop ]$ export MYKEY=~/.ssh/psrivatkey
[laptop ]$ export MYUSER=psrivast-redhat.com
Sample Output
New Vault password: redhat
Confirm New Vault password: redhat
Sample Output
Vault password: redhat
This is encrypted.
Sample Output
Vault password: redhat
Sample Output
Vault password: redhat
This is encrypted.
This is also encrypted.
Sample Output
Vault password: redhat
New Vault password: ansible
Confirm New Vault password: ansible
Rekey successful
Sample Output
Vault password: ansible
Decryption successful
Sample Output
This is encrypted.
This is also encrypted.
3. Encrypt the super-secret-decrypted.yml file and save the file aspasswd-
encrypted.yml, this time entering redhat as the vault password:
[devops@bastion ansible_implementation]$ ansible-vault encrypt
super-secret-decrypted.yml --output=super-secret-encrypted.yml
Sample Output
New Vault password: redhat
Confirm New Vault password: redhat
Encryption successful
Sample Output
New Vault password: redhat
Confirm New Vault password: redhat
Sample Output
Vault password: redhat
playbook: create_users.yml
Sample Output
PLAY [create user accounts for all our servers]
********************************
TASK [setup]
*****************************************************************
**
ok: [frontend1.${GUID}.internal]
PLAY RECAP
*****************************************************************
****
frontend1.${GUID}.internal : ok=2 changed=1
unreachable=0 failed=0