Ansible Control Node Usage Guide#
The following examples show how to utilize Ansible Control Node for routine cluster operations.
Prerequisites#
References#
Recommended Reference: https://www.ansiblefordevops.com
Deployment Steps#
Note
Instructions assume execution using the ansible
account.
Important
These examples require the following:
* The system hosting ansible is a client to a IdM server.
* The user account executing the playbooks is named “ansible”
* The “ansible” user defaults to group named “ansible”
* The “ansible” user account has sudo access on all nodes through IdM
* Passwordless SSH has been configured for the “ansible” user account
* DNS entries for all target servers
Create a directory structure:
sudo mkdir -p /srv/ansible/adhoc/ sudo mkdir -p /srv/ansible/inventory/ sudo mkdir -p /srv/ansible/playbooks/ sudo mkdir -p /srv/ansible/scripts/ sudo mkdir -p /srv/ansible/templates/ sudo chown -R ansible:ansible /srv/ansible/
Create a hosts file:
Note
An YAML based hosts file has been provided:
hosts.yml
cat > /srv/ansible/inventory/hosts.yml <<EOF all: hosts: nfs01.engwsc.example.com: vmm[01:02].engwsc.example.com: user[01:04].engwsc.example.com: comp[01:04].engwsc.example.com: idm.engwsc.example.com: gitlab.engwsc.example.com: slurm.engwsc.example.com: graylog.engwsc.example.com: ansible.engwsc.example.com: influxdb.engwsc.example.com: grafana.engwsc.example.com: docker.engwsc.example.com: mirror.engwsc.example.com: children: vmm_nodes: hosts: vmm[01:02].engwsc.example.com: user_nodes: hosts: user[01:04].engwsc.example.com: comp_nodes: hosts: comp[01:04].engwsc.example.com: storage_nodes: hosts: nfs01.engwsc.example.com: service_nodes: hosts: idm.engwsc.example.com: gitlab.engwsc.example.com: slurm.engwsc.example.com: graylog.engwsc.example.com: ansible.engwsc.example.com: influxdb.engwsc.example.com: grafana.engwsc.example.com: docker.engwsc.example.com: mirror.engwsc.example.com: idm_servers: hosts: idm.engwsc.example.com: idm_clients: hosts: nfs01.engwsc.example.com: vmm[01:02].engwsc.example.com: user[01:04].engwsc.example.com: comp[01:04].engwsc.example.com: idm.engwsc.example.com: gitlab.engwsc.example.com: slurm.engwsc.example.com: graylog.engwsc.example.com: ansible.engwsc.example.com: influxdb.engwsc.example.com: grafana.engwsc.example.com: docker.engwsc.example.com: mirror.engwsc.example.com: gitlab_servers: hosts: gitlab.engwsc.example.com: slurm_controllers: hosts: slurm.engwsc.example.com: slurm_clients: children: user_nodes: comp_nodes: graylog_servers: hosts: graylog.engwsc.example.com: rsyslog_clients: hosts: nfs01.engwsc.example.com: vmm[01:02].engwsc.example.com: user[01:04].engwsc.example.com: comp[01:04].engwsc.example.com: idm.engwsc.example.com: gitlab.engwsc.example.com: slurm.engwsc.example.com: graylog.engwsc.example.com: ansible.engwsc.example.com: influxdb.engwsc.example.com: grafana.engwsc.example.com: docker.engwsc.example.com: mirror.engwsc.example.com: ansible_controllers: hosts: ansible.engwsc.example.com: influxdb_servers: hosts: influxdb.engwsc.example.com: telegraf_clients: hosts: nfs01.engwsc.example.com: vmm[01:02].engwsc.example.com: user[01:04].engwsc.example.com: comp[01:04].engwsc.example.com: idm.engwsc.example.com: gitlab.engwsc.example.com: slurm.engwsc.example.com: graylog.engwsc.example.com: ansible.engwsc.example.com: influxdb.engwsc.example.com: grafana.engwsc.example.com: docker.engwsc.example.com: mirror.engwsc.example.com: grafana_servers: hosts: grafana.engwsc.example.com: docker_servers: hosts: docker.engwsc.example.com: mirror_servers: hosts: mirror.engwsc.example.com: EOF
Create Upgrade Nodes Playbook Example:
Note
A copy of this yaml file had been provided:
upgrade-all-nodes.yml
cat > /srv/ansible/playbooks/upgrade-all-nodes.yml <<EOF --- - name: Upgrade all nodes hosts: all become: yes remote_user: ansible tasks: - name: Upgrade all packages dnf: name: "*" state: latest EOF
Create Upgrade Nodes Helper Script Example:
Note
A copy of this bash script had been provided:
upgrade-all-nodes.sh
cat > /srv/ansible/scripts/upgrade-all-nodes.sh <<EOF #!/bin/bash ANSIBLE_HOME='/srv/ansible' ansible-playbook \ -i \${ANSIBLE_HOME}/inventory/hosts.yml \ \${ANSIBLE_HOME}/playbooks/upgrade-all-nodes.yml EOF chmod 755 /srv/ansible/scripts/upgrade-all-nodes.sh
Execute Helper Script:
cd /srv/ansible/ /srv/ansible/scripts/upgrade-all-nodes.sh