Infrastructure@Home: Configuration Management with Ansible

  • Install Ansible on the control machine
  • Copy our public SSH key to all nodes, see this guide
infrastructure/ansible.cfghosts.iniconnection_test.yml
[defaults]inventory=hosts
[raspis]raspi-3–1raspi-3–2raspi-4–1raspi-4–2raspi-0[server]linux-workstation
raspi-3–1 ansible_host=192.168.2.107raspi-3–2 ansible_host=192.168.2.104raspi-4–1 ansible_host=192.168.2.102raspi-4–2 ansible_host=192.168.2.105
[server]linux-workstation ansible_host=192.168.2.200 ansible_user=devcon
ansible -i hosts -m ping raspis
raspi-3–1 | SUCCESS => {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”},“changed”: false,“ping”: “pong”}raspi-3–2 | SUCCESS => {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”},“changed”: false,“ping”: “pong”}
- name: Test if we can connect to all nodeshosts: alltasks:- name: Ping the nodeping:
  • Line 1: A descriptive name for this playbook
  • Line 2: A reference to the nodes to which this playbook is applied. We reference the group names that we defined in the hosts.ini file
  • Line 5: The tasks that we will execute on the node
  • Each task has a descriptive name and it uses an Ansible module
  • We execute the command ping
ansible-playbook connect.yml — limit “raspi-3–1”
ansible-playbook connect.yml — limit “raspi-3–1”
infrastructure/ansible.cfghosts.inisystem/connection_test.yml

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store