Skip to content

Commit dd5b915

Browse files
committed
update
1 parent 87b76ae commit dd5b915

File tree

12 files changed

+199
-7
lines changed

12 files changed

+199
-7
lines changed

Ansible-AWS-systems-manager/site.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- name: Access EC2 using AWS SSM connection
33
hosts: nodes
44
become: true
5-
#gather_facts: false
5+
# gather_facts: false
66
vars:
77
ansible_python_interpreter: /usr/bin/python3
88
ansible_user: ssm-user
@@ -12,12 +12,12 @@
1212
ansible_aws_ssm_region: ap-southeast-1
1313
tasks:
1414
- name: Install vim
15-
ansible.builtin.package:
15+
ansible.builtin.package:
1616
name: vim
1717
state: present
1818

1919
- name: Node info
20-
debug:
20+
ansible.builtin.debug:
2121
msg: "{{ ansible_all_ipv4_addresses }}"
2222

2323
- name: OS info

Ansible-Collections-Demo/k8s-cluster-info.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212

1313
- name: Display k8s Cluster details
1414
debug:
15-
msg: "{{ pod_list }}"
15+
msg: "{{ pod_list }}"
16+

Ansible-Dynamic-Dictionary-01/dict_2.yml ansible-dynamic-dictionary-01/dict_2.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@
7272
when: favicon is defined and favicon | length > 0
7373

7474
- debug:
75-
msg: "{{ myfulldict }}"
75+
msg: "{{ myfulldict }}"
76+
77+
- name: Print hello
78+
ansible.builtin.debug:
79+
msg: "hello"
File renamed without changes.
File renamed without changes.

ansible-email/ansible-email.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: Ansible mail notification
33
hosts: localhost
4-
gather_facts: no
4+
gather_facts: false
55
vars_files:
66
vars/smtp_secrets.yml
77
vars:
@@ -20,4 +20,7 @@
2020
tasks:
2121
- name: Email notification
2222
include_role:
23-
name: send-email
23+
name: send-email
24+
- name: Testing
25+
ansible.builtin.debug:
26+
msg: Hello world!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# https://codeshare.io/X80xJM
2+
---
3+
- hosts: "{{ NODES }}"
4+
gather_facts: false
5+
6+
vars:
7+
output_file: output.txt
8+
tasks:
9+
- name: Create server output file
10+
file:
11+
path: "{{ output_file }}"
12+
state: touch
13+
owner: root
14+
group: root
15+
mode: '0644'
16+
run_once: true
17+
delegate_to: localhost
18+
19+
- name: Server details
20+
shell: |
21+
echo "$(uname -n)"
22+
echo "Old kernel: xyz"
23+
echo "Current kernel: $(uname -r)"
24+
#when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
25+
register: app
26+
27+
#- name: check with shell
28+
# shell: |
29+
# echo " {{ item }}" >> /opt/depot/dinesh/{{ chg }}-Test.txt
30+
# loop:
31+
# - "{{ app.stdout }}"
32+
# when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
33+
# delegate_to: localhost
34+
35+
- name: Store app server oututs in a file
36+
# local_action: lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
37+
lineinfile:
38+
line: "{{ item }}"
39+
insertafter: EOF
40+
path: "{{ output_file }}"
41+
#blockinfile: block=" Hi {{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
42+
loop:
43+
- "{{ hostvars[inventory_hostname].app.stdout_lines }}"
44+
#when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
45+
# ignore_errors: True
46+
delegate_to: localhost
47+
# - debug:
48+
# msg: "{{ app }}"
49+
- meta: end_play
50+
- name: Database server outputs
51+
shell: |
52+
echo "************************************************************************************"
53+
echo "$(uname -n) Output"
54+
echo "-------------------------------"
55+
echo "Old kernel: xyz"
56+
echo "Current kernel: $(uname -r)"
57+
echo "GRID services status"
58+
echo "--------------------"
59+
echo "No GRID setup found on server"
60+
when: "'ora' in inventory_hostname"
61+
register: db
62+
- name: Postgres Database server outputs
63+
shell: |
64+
echo "************************************************************************************"
65+
echo "$(uname -n) Output"
66+
echo "-------------------------------"
67+
echo "Old kernel: xyz"
68+
echo "Current kernel: $(uname -r)"
69+
ps -ef | grep /pgsql | grep -v grep > /dev/null
70+
if [[ $? == 0 ]]; then echo "DB Checkout: Success"; else echo "DB Checkout: Fail"; fi
71+
echo "-------------------------------"
72+
when: " 'ql' in inventory_hostname"
73+
register: pgsql
74+
- name: Sybase Database server outputs
75+
shell: |
76+
echo "************************************************************************************"
77+
echo "$(uname -n) Output"
78+
echo "-------------------------------"
79+
echo "Old kernel: xyz"
80+
echo "Current kernel: $(uname -r)"
81+
ps -ef | grep IQ | grep -v grep > /dev/null
82+
if [[ $? == 0 ]]; then echo "DB Checkout: Success"; else echo "DB Checkout: Fail"; fi
83+
echo "-------------------------------"
84+
when: "'syb' in inventory_hostname"
85+
register: syb
86+
# - name: Store app server oututs in a file
87+
# local_action: lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
88+
# loop:
89+
# - "{{ app.stdout | default()}}"
90+
# when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
91+
# ignore_errors: True
92+
# - meta: end_play
93+
- name: Store Oracle database server outputs in a file
94+
local_action: lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
95+
loop:
96+
- "{{ db.stdout | default() }}"
97+
when: "'ora' in inventory_hostname"
98+
ignore_errors: True
99+
- name: Store Postgres database server outputs in a file
100+
local_action: lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
101+
loop:
102+
- "{{ pgsql.stdout | default() }}"
103+
when: "'ql' in inventory_hostname"
104+
ignore_errors: True
105+
- name: Store Sybase database server outputs in a file
106+
local_action: lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
107+
loop:
108+
- "{{ syb.stdout | default() }}"
109+
when: "'syb' in inventory_hostname"
110+
ignore_errors: True

ansible-multi-list-loop/ansible.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
inventory = ./hosts

ansible-multi-list-loop/hosts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[me]
2+
localhost ansible_connection=local
3+
4+
[node]
5+
node1 ansible_host=localhost ansible_port=2222 ansible_user=vagrant ansible_password=vagrant ansible_ssh_common_args='-o StrictHostKeyChecking=no -o PreferredAuthentications=password'

ansible-multi-list-loop/site.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: "Multi List Loop"
3+
hosts: localhost
4+
vars:
5+
fruits:
6+
- "apple"
7+
- "mango"
8+
- "orange"
9+
color:
10+
- "red"
11+
- "yellow"
12+
- "green"
13+
tasks:
14+
- name: "Loop with multiple list"
15+
debug:
16+
msg: "{{ item[0] }} {{ item[1] }}"
17+
with_nested:
18+
- '{{ color }}'
19+
- '{{ fruits }}'

ansible-network-automation/site.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
#- name: Write memory
3+
# cisco.asa.asa_command:
4+
# commands:
5+
# - write memory
6+
#
7+
#- name: Take Cisco ASA Backup
8+
# cisco.asa.asa_config:
9+
# backup: yes
10+
# backup_options:
11+
# dir_path: "{{ hostvars[inventory_hostname].temp_backup_location.path }}"
12+
# filename: "{{ backup_file_name }}"
13+
# register: cisco_asa_backup_status
14+
15+
#- debug:
16+
# msg: "{{ cisco_asa_backup_status }}"
17+
18+
#- name: Upload file to tftp server
19+
# ansible.builtin.shell: |
20+
# tftp {{ tftp_server }} <<EOF
21+
# put "{{ cisco_asa_backup_status.backup_path }}"
22+
# quit
23+
# EOF
24+
# args:
25+
# chdir: "{{ hostvars[inventory_hostname].temp_backup_location.path }}"
26+
# delegate_to: localhost
27+
# register: ftp_upload_status
28+
# #when: a is defined
29+
#
30+
#- debug:
31+
# msg: "{{ ftp_upload_status }}"
32+
#- debug:
33+
# msg: "{{ hostvars[inventory_hostname].temp_backup_location.path }}"
34+
35+
#- name: Upload file to tftp server
36+
# ansible.builtin.shell: |
37+
# curl -T {{ hostvars[inventory_hostname].temp_backup_location.path }}/{{ backup_file_name }} tftp://{{ tftp_server }}:{{ tftp_server_port }}
38+
# delegate_to: localhost
39+
# ignore_errors: true
40+
# register: ftp_upload_status
41+
42+
#- debug:
43+
# msg: "{{ ftp_upload_status }}"
44+
45+
46+
47+
48+

0 commit comments

Comments
 (0)