-
Notifications
You must be signed in to change notification settings - Fork 1
/
7.variables.yml
114 lines (103 loc) · 3.53 KB
/
7.variables.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
--- # ------------------------------
# The playbook is used to update name server entry into resolv.conf file on localhost.
# The name server information is also updated in the inventory file as a variable 'nameserver_ip'.
# Refer to the inventory.txt file.
# Replace the ip of the name server in this playbook to use the value from the inventory file,
# so that in the future if you had to make any changes you simply have to update the inventory file.
# ------------------------------
# BEFORE
# ------------------------------
#-
# name: Update nameserver entry into resolv.conf file on localhost
# hosts: localhost
# tasks:
# -
# name: Update nameserver entry into resolv.conf file
# lineinfile:
# path: /etc/resolv.conf
# line: 'nameserver 10.1.250.10'
# ------------------------------
# AFTER
- name: Update nameserver entry into resolv.conf file on localhost
hosts: localhost
tasks:
- name: Update nameserver entry into resolv.conf file
lineinfile:
path: /etc/resolv.conf
line: "nameserver {{ nameserver_ip }}"
# We have added a new task to disable SNMP port in the playbook. However the port is hardcoded in the playbook.
# Update the inventory file to add a new variable "snmp_port" and assign the value used here.
# Then update the playbook to use value from the variable.
# Remember to use quotes around the variable name.
# ------------------------------
# BEFORE
# ------------------------------
#-
# name: Update nameserver entry into resolv.conf file on localhost
# hosts: localhost
# tasks:
# -
# name: Update nameserver entry into resolv.conf file
# lineinfile:
# path: /etc/resolv.conf
# line: 'nameserver {{ nameserver_ip }}'
#
# -
# name: Disable SNMP Port
# firewalld:
# port: 160-161
# permanent: true
# state: disabled
# ------------------------------
# AFTER
# ------------------------------
- name: Update nameserver entry into resolv.conf file on localhost
hosts: localhost
tasks:
- name: Update nameserver entry into resolv.conf file
lineinfile:
path: /etc/resolv.conf
line: "nameserver {{ nameserver_ip }}"
- name: Disable SNMP Port
firewalld:
port: "{{ snmp_port }}"
permanent: true
state: disabled
# We are printing some personal information to the screen. We would like to move the car_model,
# country_name and title to a variable defined at the play level.
# Create three new variables (car_model, country_name and title) under
# the play and move the values over. Use the variables in the task.
# ------------------------------
# BEFORE
# ------------------------------
#-
# name: Update nameserver entry into resolv.conf file on localhost
# hosts: localhost
# tasks:
# -
# name: Print my car model
# command: echo "My car's model is BMW M3"
#
# -
# name: Print my country
# command: echo "I live in the USA"
#
# -
# name: Print my title
# command: echo "I work as a Systems Engineer"
# ------------------------------
# AFTER
# ------------------------------
- name: Update nameserver entry into resolv.conf file on localhost
hosts: localhost
vars:
car_model: BMW M3
country_name: USA
title: Systems Engineer
tasks:
- name: Print my car model
command: echo "My car's model is {{ car_model }}"
- name: Print my country
command: echo "I live in the USA {{ country_name }}"
- name: Print my title
command: echo "I work as a {{ title }}"