Difference between revisions of "Ansible Howto"
From Cactus Howto
Jump to navigationJump to searchLine 13: | Line 13: | ||
= ansible advanced topics = |
= ansible advanced topics = |
||
== use |
== use cases debian/ubuntu sys management using apt == |
||
This only works for ansible >=2.4. |
|||
tim@spike-vm:~/ansi$ ansible-playbook -l puppet apt-autoremove.yml -K |
|||
⚫ | |||
<pre> |
|||
tim@spike-vm:~/ansi$ cat apt-autoremove.yml |
|||
--- |
|||
- hosts: all |
|||
become: yes |
|||
tasks: |
|||
- name: Autoremove unused packages |
|||
apt: |
|||
autoremove: yes |
|||
when: > |
|||
ansible_distribution == 'Debian' |
|||
or |
|||
ansible_distribution == 'Ubuntu' |
|||
</pre> |
|||
⚫ | |||
tim@spike-vm:~/ansi$ ansible-playbook -l puppet apt-install.yml -K -e "package=apache2" |
tim@spike-vm:~/ansi$ ansible-playbook -l puppet apt-install.yml -K -e "package=apache2" |
||
Line 44: | Line 62: | ||
or |
or |
||
ansible_distribution == 'Ubuntu' |
ansible_distribution == 'Ubuntu' |
||
== use case change passwords for linux systems == |
|||
== use case add firewall rule == |
== use case add firewall rule == |
Revision as of 11:42, 17 November 2018
ansible first steps
documentation
installation
On ubuntu / debian:
sudo apt install ansible
initial config
Edit /etc/ansible/hosts
ansible advanced topics
use cases debian/ubuntu sys management using apt
This only works for ansible >=2.4.
tim@spike-vm:~/ansi$ ansible-playbook -l puppet apt-autoremove.yml -K
tim@spike-vm:~/ansi$ cat apt-autoremove.yml --- - hosts: all become: yes tasks: - name: Autoremove unused packages apt: autoremove: yes when: > ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
use case install apt package
tim@spike-vm:~/ansi$ ansible-playbook -l puppet apt-install.yml -K -e "package=apache2" SUDO password: PLAY [all] ********************************************************************* TASK [setup] ******************************************************************* ok: [puppet] TASK [install package "apache2"] *********************************************** ok: [puppet] PLAY RECAP ********************************************************************* puppet : ok=2 changed=0 unreachable=0 failed=0
tim@spike-vm:~/ansi$ cat apt-install.yml --- - hosts: all become: yes tasks: - name: install package "Template:Package" apt: name: apache2 when: > ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'