- Master Node
- OS: RHEL8.5
- Memory: 2GB
- Ansible version 2.9
- Cloned Virtual Machines
- OS: CentOS Stream 8.5
- Memory: 1GB
- Quantity: 3x (or more)
Install required packages To be able to run Ansible, some packages are required:
- OpenSSH-Server (should be installed by default)
- Python3 (should be installed by default)
- Ansible-Engine
Installing Ansible-Engine on RHEL 8.5
🖥️ at the prompt:
# these 3 commands maybe take a while to run
sudo subscription-manager repos | grep -i ansible-2.9
sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpms
sudo dnf install ansible -y
### Version check
ansible --version
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /bin/ansible
python version = 3.6.8 (default, Sep 9 2021, 07:49:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
-
On each node include the master node create an ansible user.
sudo useradd ansible
sudo passwd ansible
-
Create an ssh key on the master node and copy it to the managed nodes. Go through the defaults in the prompt by hitting 'enter'. No need to create a passphrase.
- On the master note:
ssh-keygen
- Copy the key to managed nodes (provide node password):
ssh-copy-id ansible@nodename
- On the master note:
-
Verify access through an ad hoc ping
ansible all -m ping # Successful Output node1 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false, "ping": "pong" } node3 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false, "ping": "pong" } node2 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false, "ping": "pong" }
This setup purely optional, but may improve your speed while taking the exam. YAML does not accept tabs, instead use 2 spaces. The best way to simplify this is to setup tabstops in your ~/.vimrc
file to make this automatic.
📃 ~/.vimrc
set undofile
set undodir="~/.vim/undo"
Make sure to create the undo directory.
🖥️ at the prompt: mkdir -p ~/.vim/undo
-
If you find the
autocmd
hard to remember you could specify instead:set tabstop=2 softtabstop=2
-
Ansible often gives line numbers in errors, so seeing them at a glance can help:
set number
will enable line numbers in files you're working on.