Commit f795d8fe authored by Akshay's avatar Akshay

added yaml files

parent 7f60fa9b
# Ansible
This is a demo repo
---
- hosts: all
become: true
vars_files:
- vars/default.yml
tasks:
- name: Install prerequisites
apt: name={{ item }} update_cache=yes state=latest force_apt_get=yes
loop: [ 'aptitude' ]
- name: Install Apache
apt: name=apache2 update_cache=yes state=latest
- name: Create document root
file:
path: "/var/www/{{ http_host }}"
state: directory
owner: "{{ app_user }}"
mode: '0755'
- name: Copy index test page
template:
src: "files/index.html.j2"
dest: "/var/www/{{ http_host }}/index.html"
- name: Set up Apache virtuahHost
template:
src: "files/apache.conf.j2"
dest: "/etc/apache2/sites-available/{{ http_conf }}"
- name: Enable new site
shell: /usr/sbin/a2ensite {{ http_conf }}
notify: Reload Apache
- name: Disable default Apache site
shell: /usr/sbin/a2dissite 000-default.conf
when: disable_default
notify: Reload Apache
- name: "UFW - Allow HTTP on port {{ http_port }}"
ufw:
rule: allow
port: "{{ http_port }}"
proto: tcp
handlers:
- name: Reload Apache
service:
name: apache2
state: reloaded
- name: Restart Apache
service:
name: apache2
state: restarted
---
- hosts: test-servers
become: true
tasks:
- name: update apt list
apt:
update_cache: yes
- name: Install Apache
apt: name=apache2 update_cache=yes state=latest
handlers:
- name: Reload Apache
service:
name: apache2
state: reloaded
- name: Restart Apache
service:
name: apache2
state: restarted
---
- hosts: test-servers
become: true
tasks:
- name: update apt list
apt:
update_cache: yes
- name: Install Apache
apt: name=apache2 update_cache=yes state=latest
handlers:
- name: Reload Apache
service:
name: apache2
state: reloaded
- name: Restart Apache
service:
name: apache2
state: restarted
---
- name: Hello World!
hosts: all
tasks:
- name: Hello World!
shell: echo "Hi! Tower is working."
---
- hosts: all
become: true
tasks:
- name: update apt list
apt:
update_cache: yes
- name: Install Apache
apt: name=apache2 update_cache=yes state=latest
handlers:
- name: Reload Apache
service:
name: apache2
state: reloaded
- name: Restart Apache
service:
name: apache2
state: restarted
- name: Create Folder
hosts: all
tasks:
- name: create folder
file:
path: /demo/testfo
state: directory
- name: Create Folder
hosts: all
tasks:
- name: create folder
file:
path: /root/testfolder
state: directory
---
- hosts : test-servers
become : true
tasks :
- name : install nginx
package : pkg=nginx state=latest
notify:
- start nginx
- name : create new dir
file :
path: ndirec
state : directory
mode : '0555'
owner : "{{ ansible_user }}"
group : "{{ ansible_user }}"
- name : install apache2
package : pkg=apache2 state=latest
notify:
- start Apache2
handlers :
- name : start nginx
service : name=nginx state=started
---
- hosts : all
become : true
tasks :
- name : install apache2
apt : name=apache2 update_cache=yes state=latest
notify: start Apache2
handlers :
- name : Reload Apache
service :
name: apache2
state: reloaded
- name : Restart Apache
service :
name: apache2
state: restarted
---
- hosts: all
become: yes
become_method: sudo
become_user: demo
tasks:
- name: update apt list
apt:
update_cache: yes
- name: Install Apache
apt: name=apache2 update_cache=yes state=latest
handlers:
- name: Reload Apache
service:
name: apache2
state: reloaded
- name: Restart Apache
service:
name: apache2
state: restarted
---
- hosts : test-servers
become : true
vars :
ansible_become_pass : 1
tasks :
apt:
name: ['nginx']
state: latest
handlers:
- name: restart nginx
service:
name: nginx
state: restart
...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment