Ansible Sibelius Module Explained
---
- name: Stop and Start ssh
service:
name: ssh
state: stopped
- name: Stop and Start ssh
service:
name: ssh
state: started
ansible-playbook -i localhost mainplaybook.yml
LOOPS:
ansible loops- ansible siblius -working
loops
type the below in the defaults/mail.yml
---
mongo_packages:
- apache2
- sqlite3
- git
type the below in tasks/main.yml
---
- name: Install mongodb
yum:
name: "{{ item }}"
state: present
with_items: "{{ mongo_packages }}"
Ansible When Clause:
#Create the directory using the adhoc command
step1 : run this in terminal
ansible localhost -m ansible.builtin.file -a "dest=/home/user/test mode=755
state=directory"
step :2 create a file named simplefile.txt
touch simplefile.txt
click File->new file
name the file as simplefile.txt
step :3 main.yml
---
- name: check destination
stat:
path: /home/user/test/simplefile.txt
register: p
- name: copy file if not exists
command: mv /projects/challenge/simplefile.txt /home/user/test
when: p.stat.exists == False
Ansible Sibelius Handon
Ansible sibelius - Try It Out-Write A Playbook
- name: Install nginx
apt:
name: nginx
state: latest
- name: Start NGiNX
service:
name: nginx
state: started
- name: Install PostgreSQL
apt:
name: postgresql
state: latest
- name: Start PostgreSQL
service:
name: postgresql
state: started
then run
ansible-playbook -i myhosts test.yml
ansible-playbook -i myhosts mainplaybook.yml
ansible-playbook -i myhosts master_playbook.yml