Bootstrap Nodes with Python using Ansible
As Ansible depends on Python, Python is needed for using Ansible. To bootstrap nodes with Python, you can use the following Playbook:
Inventory
inventory.ini
[admin] localhost [new] docker-node-1 glusterfs-node-1 glusterfs-node-2 elasticsearch-node-1 elasticsearch-node-2 [admin:vars] location_country="South Africa" location_city="Cape Town" [new:vars] ansible_python_interpreter=/usr/bin/python3 location=europe
Playbook
bootstrap-python.yml
--- - hosts: all gather_facts: False tasks: - name: install python raw: test -e /usr/bin/python || ( apt update && apt install python -y ) - name: install htop raw: test -e /usr/bin/htop || ( apt update && apt install htop -y )
Running Ansible
$ ansible-playbook -i inventory.ini bootstrap-python.yml PLAY [all] *********************************************************************************************************************************************************************************************** TASK [install python] ************************************************************************************************************************************************************************************ changed: [docker-node-1] changed: [elasticsearch-node-1] changed: [glusterfs-node-2] changed: [glusterfs-node-1] changed: [elasticsearch-node-2] changed: [localhost] TASK [install htop] ************************************************************************************************************************************************************************************** changed: [docker-node-1] changed: [glusterfs-node-1] changed: [glusterfs-node-2] changed: [elasticsearch-node-1] changed: [elasticsearch-node-2] changed: [localhost] PLAY RECAP *********************************************************************************************************************************************************************************************** docker-node-1 : ok=2 changed=2 unreachable=0 failed=0 elasticsearch-node-1 : ok=2 changed=2 unreachable=0 failed=0 elasticsearch-node-2 : ok=2 changed=2 unreachable=0 failed=0 glusterfs-node-1 : ok=2 changed=2 unreachable=0 failed=0 glusterfs-node-2 : ok=2 changed=2 unreachable=0 failed=0 localhost : ok=2 changed=2 unreachable=0 failed=0