If you do not have Ansible already installed then you can install using the command below. (All commands and files used are available for download at the end of the guide)
yum install ansible -y
2. Use vim ansible.cfg to create the ansible configuration file and populate the file with the following. (You can download the code and the file at the end of this guide)
The above is a simple configuration file for ansible in which the default section defines the host_inventory file that will have the list of hosts and what user to connect as to the remote nodes. The privilege_escalation indicates that its is a ssh-key based login with no password and commands are run with root privileges.
3. Now we will create the inventory file which is a simple file with the names of hosts. You can use your favorite editor to create this file. I am using vim host_inventory. This inventory files consists of 12 hosts, devhost01-devhost10, devhosta and devhostb (This file is available to download at the end of the guide.)
4. We will now create a simple ansible playbook to install the php and mariadb packages on all the hosts in the listed inventory. Watch the indentation as YAML is “indent-sensitive”. (You can download this file at the end of the guide)
This playbook installs php and mariadb packages on all hosts defined in the inventory file
5. Run the playbook using the command ansible-playbook install_packages.yml
If you have new hosts to add, simply go to the inventory file, add the hosts and run the playbook again. If you need to add packages like httpd then go to the install_packages.yml file and add the package name and run the playbook again. You can run the playbook any number of times since Ansible is a desired state engine, which means that if the packages are not present then it will install the packages and if they are present then it will just skip those making package installation a breeze for system admins regardless of the number of systems.
April 28, 2021 |
April 21, 2021 |
April 14, 2021 | AS400/IBMi
Join our mailing list to receive the latest news and updates from our team.