Ansible Sibelius

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Ansible - Sibelius

Design Goal of ansible include - all


YAML uses tab - false
YAML syntax - path:f: i\test
ansible is - all
ansible aquired by - red hat
agentless -
design goal of ansible includes -

HANDSON

----------------------------------------------------------------
Module Explained - do as per instruction given
----------------------------------------------------------------
When Clause
---------------------------------------------------------------
echo "[group1]" > myhosts
echo "host01 ansible_ssh_user=ubuntu" >> myhosts

ansible host01 -i myhosts -m command -a "mkdir /home/ubuntu/folder1"

touch somefile.j2

vi test.yml

---
- name: When clause test
hosts: all
tasks:
- stat: path=/home/ubuntu/folder1/somefile.j2
register: st
- template: src=somefile.j2 dest=/home/ubuntu/folder1/somefile.j2
when: not st.stat.exists

:wq

ansible-playbook -i myhosts test.yml


-------------------------------------------------------------------
loop
------------------------------------------------------------------
echo "[group1]" > myhosts
echo "host01 ansible_ssh_user=ubuntu" >> myhosts

vi test.yml

---
- hosts: all
sudo: yes
tasks:
- name: install apache2
apt: name=apache2 update_cache=yes state=latest
- name: install sqlite3
apt: name=sqlite3 update_cache=yes state=latest
- name: install git
apt: name=git update_cache=yes state=latest

:wq

ansible-playbook -i myhosts test.yml


-----------------------------------------------------------------------
Write a playbook
------------------------------------------------------------------------

echo "host01 ansible_ssh_user=ubuntu" >> myhosts

vi test.yml

---
- hosts: all
sudo: yes
tasks:
- name: install nginx
apt: name=nginx update_cache=yes state=latest
service: name=nginx state=started enabled=yes
- name: install postgresql
apt: name=postgresql update_cache=yes state=latest
service: name=postgresql state=started enabled=yes

:wq

Move to step 2 of 2

do again following steps

vi test.yml

Modify the details as per below

---
- hosts: all
sudo: yes
tasks:
- name: install nginx
apt: name=nginx update_cache=yes state=latest
- name: install postgresql
apt: name=postgresql update_cache=yes state=latest

:wq

ansible-playbook -i myhosts test.yml


--------------------------------------------

ansible-playbook -i myhosts tag.yml --tags "tag1"


ansible-playbook -i myhosts tag.yml --tags "tagged"

ansible-playbook -i myhosts tag.yml --tags "untagged"

ansible-playbook -i myhosts tag.yml --tags "untagged" --skip-tags "always"

You might also like