Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[webservers]
192.168.147.187 ansible_user=root
19 changes: 19 additions & 0 deletions playbooks/01_app_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Install and Start the service
hosts: all
vars:
- app: httpd

tasks:
- name: Installing nginx
yum:
name: "{{ app }}"
state: present
tags: i-nginx

- name: Starting the nginx service
service:
name: "{{ app }}"
state: started
enabled: true
tags: ss-nginx
13 changes: 13 additions & 0 deletions playbooks/02_copy_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Copying files to remote
hosts: all

tasks:
- name: Copy files
copy:
src: /root/myfile.txt
dest: /tmp/
owner: paul
group: paul
mode: ugo=rw
backup: true
17 changes: 17 additions & 0 deletions playbooks/03_files_mod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: File Module
hosts: all

tasks:
- name: Creating a file
file:
path: /tmp/newfile.txt
state: absent
owner: paul
group: paul
mode: u=rwx,g=rw,o=r

- name: Creating a directory
file:
path: /tmp/myfolder
state: absent
9 changes: 9 additions & 0 deletions playbooks/04_change_permission.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: change permissions
hosts: all

tasks:
- name: change perm
file:
path: /tmp/myfile.txt
mode: u=r,g=rw
10 changes: 10 additions & 0 deletions playbooks/05_script_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Run a script
hosts: all

tasks:
- name: Run script
shell: ./test.sh >> test.log
args:
chdir: /tmp/script/
creates: test.log
16 changes: 16 additions & 0 deletions playbooks/06_cron_jobs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Cron Setup
hosts: all

tasks:
- name: Add Cron Job
cron:
name: Run Test Script
minute: 30
hour: 20
day: 15
month: "*"
weekday: "*"
user: paul
job: /tmp/script/test.sh
disabled: yes
13 changes: 13 additions & 0 deletions playbooks/07_cron_modify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Modify Cron
hosts: all

tasks:
- name: Remove Cron Job
cron:
name: VARR
env: yes
user: paul
job: /tmp/script/test.sh
insertafter: PATH
state: absent
14 changes: 14 additions & 0 deletions playbooks/08_user_mgm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: User Mgm
hosts: all

tasks:
- name: User Creation
user:
name: "{{ item }}"
comment: new user adding for QA Team
shell: /bin/bash
loop:
- Raju
- Sham
- Baburao
10 changes: 10 additions & 0 deletions playbooks/09_set_passwd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Set Password
hosts: all

tasks:
- name: Set passwd
user:
name: nick
update_password: always
password: "{{'abcd12345' | password_hash('sha512', 'mysecretcode')}}"
12 changes: 12 additions & 0 deletions playbooks/10_download_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Downlaod files
hosts: all

tasks:
- name: Download file
get_url:
url: https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz
dest: /tmp/script/
owner: paul
group: paul
mode: 0777
13 changes: 13 additions & 0 deletions playbooks/11_kill_process.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Kill a process
hosts: all

tasks:
- name: Find a process and kill it
ignore_errors: yes
shell: "pgrep nginx | xargs kill"

- name: Start the service
service:
name: nginx
state: started
21 changes: 21 additions & 0 deletions playbooks/12_firewalld.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Firewall changes
hosts: all
become: true

tasks:
- name: Enable a service in firewalldd
firewalld:
port: 80/tcp
permanent: true
state: disabled
notify:
- Reload firewalld

handlers:
- name: Reload firewalld
service:
name: firewalld
state: reloaded


16 changes: 16 additions & 0 deletions playbooks/13_conditions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Installing Httpd
hosts: all

tasks:
- name: Install httpd on Redhat
yum:
name: httpd
state: present
when: ansible_os_family == "RedHat"

- name: Install apache2 on Ubuntu
apt:
name: apache2
state: present
when: ansible_os_family == "Ubuntu"
16 changes: 16 additions & 0 deletions playbooks/14_for_loop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Install and Start the service
hosts: all
vars:
- apps: [yum,httpd,vim,telnet]

tasks:
- name: Installing nginx
yum:
name: "{{ item }}"
state: present
tags: i-nginx
with_items: "{{ apps }}"



9 changes: 9 additions & 0 deletions playbooks/first_pb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: First Basic PB
hosts: all

tasks:
- name: Test Connectivity
ping:
- name: "Print Output"
debug: msg="Alright!!"
6 changes: 6 additions & 0 deletions playbooks/roles_demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Install httpd and Firewall changes
hosts: all
roles:
- httpd_setup
- fwd_service
18 changes: 18 additions & 0 deletions playbooks/webserver_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- name: Upload new code and ReStart the service
hosts: localhost:90
vars:
app: httpd

tasks:
- name: Place custom HTML File
copy:
src: /var/lib/jenkins/workspace/website-update/index.html
dest: /var/www/html/index.html
become: true

- name: Start the service
service:
name: httpd
state: restarted
enabled: yes
become: true
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
print("Wassup Buddy!! v9")
print("Wassup Abhi v2!!")