Skip to content

Commit 9304cc0

Browse files
author
lerndevops
authored
Add files via upload
1 parent 9f3c691 commit 9304cc0

19 files changed

+675
-0
lines changed

ansible/playbooks/06copy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- hosts: all
3+
become: true
4+
tasks:
5+
- name: Copy ansible inventory file to all hostmachines
6+
copy: src=/etc/ansible/ansible.cfg
7+
dest=/tmp/
8+
owner=root
9+
group=root
10+
mode=0666
11+
...

ansible/playbooks/07loops1.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#This playbbok will install HTTP server,wget and vim package using loops.
2+
3+
---
4+
- hosts: localhost
5+
become: true
6+
tasks:
7+
- name: Install list of packages
8+
yum: name='{{item}}' state=present
9+
with_items:
10+
- httpd
11+
- wget
12+
- vim
13+
- zip
14+
- unzip
15+
...

ansible/playbooks/ansible.cfg

Lines changed: 475 additions & 0 deletions
Large diffs are not rendered by default.

ansible/playbooks/cond.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- hosts: aws
3+
become: yes
4+
tasks:
5+
- name: install a webserver
6+
yum:
7+
name: httpd
8+
state: latest
9+
when: ansible_distribution == 'RedHat'
10+
- name: start the service
11+
service:
12+
name: httpd
13+
state: started

ansible/playbooks/facts.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- hosts: aws
3+
# gather_facts: NO
4+
tasks:
5+
- name: Checking the OS of the server
6+
debug:
7+
msg: "OS vendor = {{ ansible_distribution }}"

ansible/playbooks/file.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- hosts: aws
3+
# become: yes
4+
tasks:
5+
- name: Create a new file
6+
file:
7+
path: /tmp/newfolder
8+
state: directory
9+

ansible/playbooks/find.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
- hosts: aws
2+
become: yes
3+
tasks:
4+
- name: find the files
5+
find:
6+
paths: '/opt'
7+
patterns: "*.log"
8+
register: out
9+
10+
- name: remove the files
11+
file:
12+
path: "{{item.path}}"
13+
state: absent
14+
with_items: "{{out.files}}"

ansible/playbooks/gitclone.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- hosts: was
2+
become: yes
3+
tasks:
4+
- name: Install Git
5+
yum: name=git state=present
6+
- name: git clone
7+
git:
8+
repo: 'https://github.com/lerndevops/labs'
9+
dest: /home

ansible/playbooks/loop.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- hosts: aws
2+
tasks:
3+
- name: Run a loop
4+
debug:
5+
msg: "{{item}}"
6+
with_items:
7+
- one
8+
- two
9+
- three
10+
- Four

ansible/playbooks/ngnix.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- hosts: aws
3+
become: Yes
4+
tasks:
5+
- name: Installs nginx web server
6+
yum: name=httpd state=installed update_cache=true
7+
notify:
8+
- start nginx
9+
# - name: Remove index.html for host
10+
# file:
11+
# path: /usr/share/nginx/html/index.html
12+
# state: absent
13+
# when: php|success
14+
# - name: Upload default index.html for host
15+
# copy: src=index.html dest=/usr/share/nginx/html mode=0644
16+
handlers:
17+
- name: start nginx
18+
service: name=httpd state=started
19+

ansible/playbooks/one.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- hosts: ubuntu
2+
tasks:
3+
- debug:
4+
msg: "{{ansible_local.sample.ENV}}"

ansible/playbooks/ping.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- hosts: ubuntu
3+
gather_facts: No
4+
tasks:
5+
- name: Check Ping Connectivity
6+
ping:

ansible/playbooks/print.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- hosts: aws
3+
tasks:
4+
- name: printing a message
5+
debug:
6+
msg: "Hello Devops People "

ansible/playbooks/regi.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- hosts: aws
2+
tasks:
3+
- shell: ls /tmp
4+
register: out
5+
6+
- debug:
7+
msg: "{{out.stdout_lines}}"

ansible/playbooks/role1.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- hosts: aws
3+
roles:
4+
- role1

ansible/playbooks/shell.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- hosts: aws
3+
become: yes
4+
tasks:
5+
- name : execute a shell
6+
shell: touch /tmp/ravi
7+
# register: abc
8+
# - debug:
9+
# msg: "{{ abc.stdout_lines }}"
10+
# - name : execute a command
11+
# command: echo " executing a command"
12+
13+
14+
15+
16+

ansible/playbooks/stat.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
- hosts: aws
2+
become: yes
3+
tasks:
4+
- name: Check that the file exists
5+
stat:
6+
path: /tmp/file.txt
7+
register: stat_result
8+
9+
- name: Create the file, if it doesnt exist already
10+
file:
11+
path: /tmp/file.txt
12+
state: touch
13+
when: stat_result.stat.exists == False

ansible/playbooks/tags.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
- hosts: localhost
3+
become: yes
4+
tasks:
5+
- name: Install Apache HTTP server on RedHat Server
6+
tags:
7+
- install
8+
yum:
9+
name: httpd
10+
state: present
11+
when: ansible_os_family == "RedHat"
12+
- name: Install Apache HTTP server on Ubuntu server
13+
tags:
14+
- install
15+
- start
16+
apt:
17+
name: apache2
18+
state: present
19+
when: ansible_os_family == "Debian"
20+
- name: Install Apache HTTP server on CentOS server
21+
yum:
22+
name: httpd
23+
state: present
24+
when:
25+
- ansible_facts['distribution'] == "CentOS"
26+
- ansible_facts['distribution_major_version'] == "7"
27+
- name: Print the Ansible free memory
28+
debug:
29+
msg: "free memory is {{ansible_memory_mb.real.free}}"

ansible/playbooks/vari.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- hosts: aws
2+
vars:
3+
PACKAGE: ClassPackage
4+
x: GM
5+
tasks:
6+
- debug:
7+
# msg: "the value of PACKAGE = {{PACKAGE}}"
8+
msg: "the value of x = {{x}}"

0 commit comments

Comments
 (0)