/etc/ansible/hosts
¶[databases]
database01.example.com
database02.example.com
[webservers]
web.example.com
[databases]
database01.example.com postgresql_version=12.3
database02.example.com postgresql_version=10.13
[webservers]
web.example.com ansible_user=admin
Example:
# task list
- walk the dog
- mow the lawn
# talk description - nested objects
talks:
automation_101:
id: 101
title: "Automation 101 w/ Ansible"
keywords:
- ansible
- automation
example:
- name: Configure hosts files
template:
src: /home/user/ansible/templates/hosts.j2
dest: /etc/hosts
/home/user/ansible/templates/hosts.j2
:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 {{ development_hostname }}
development_hostname
could be, for example: www.example.com
example:
- hosts: databases
tasks:
- name: Configure postgres database
template:
src: /home/user/ansible/templates/pg_hba.j2
dest: /var/lib/pgsql/pg_hba.conf
- name: Upgrade postgres via pg_upgrade
command: pg_upgrade -b /dbbackup -B /var/lib/pgsql/data -d /dbconfig -D /var/lib/pgsql
If in a file named update_postgres.yml
, can be invoked as ansible-playbook update_postgres.yml
Thank you for attending!
Feedback form https://forms.gle/9E8pdkJ9jR9ybfSk7.
Presentation link https://kahowell.net/presentations/2020-06-13_automation_101_ansible/automation_101_ansible.slides.html.