ANSIBLE
FOR DUMMIES
Inventories
- Servers to setup
[web1]
123.123.123.123 ansible_become_user=root
[web2]
123.123.123.124 ansible_become_pass=pswd
[web:children]
web1
web2SSH config
...
Host testing
HostName 123.123.123.123
User ubuntu
IdentityFile ~/.ssh/test
...Playbook
---
- hosts: testing
roles:
- redis
tasks:
- name: Ensure user exists
become: yes
user:
name: redis
state: presentGoing Deeper
---
- name: Ensure redis is installed
become: yes
apt:
name: redis-server
state: present
when: ansible_os_family == 'Debian'
- name: Ensure redis is installed
become: yes
yum:
name: redis
state: present
when: ansible_os_family == 'RedHat'
Galaxy
ansible-galaxy install datadog-galaxy.php70ansible-galaxy install datadog-galaxy.nginx...
roles:
- redis
- datadog-galaxy.php70
- datadog-galaxy.nginx
...Vault
ansible-vault create src/group_vars/allansible-vault edit src/group_vars/all...
db_username: root
db_password: 123456
...ansible-playbook -i src/inventories/testing src/setup.yml --ask-vault-passansible-playbook -i src/inventories/testing src/setup.yml --vault-password-file ~/.pass.txtHomework
- Make playbook for your project (php+mysql+nginx)
- Make playbook for other distro (ubuntu+archlinux)
Q&A
+
- What do you want for the next session?
Ansible For Dummies
By Vaidas Mikalauskas
Ansible For Dummies
- 2,031