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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
| PLAY [all] ****************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************
ok: [192.168.142.20]
TASK [define users in a loop] *********************************************************************************************
changed: [192.168.142.20] => (item=root)
changed: [192.168.142.20] => (item=nginx)
TASK [show users] *********************************************************************************************************
ok: [192.168.142.20] => {
"msg": {
"changed": true,
"msg": "All items completed",
"results": [
{
"ansible_loop_var": "item",
"changed": true,
"cmd": "grep root /etc/passwd",
"delta": "0:00:00.003829",
"end": "2023-08-30 16:05:18.237586",
"failed": false,
"invocation": {
"module_args": {
"_raw_params": "grep root /etc/passwd",
"_uses_shell": true,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"item": "root",
"rc": 0,
"start": "2023-08-30 16:05:18.233757",
"stderr": "",
"stderr_lines": [],
"stdout": "root:x:0:0:root:/root:/bin/bash\noperator:x:11:0:operator:/root:/sbin/nologin",
"stdout_lines": [
"root:x:0:0:root:/root:/bin/bash",
"operator:x:11:0:operator:/root:/sbin/nologin"
]
},
{
"ansible_loop_var": "item",
"changed": true,
"cmd": "grep nginx /etc/passwd",
"delta": "0:00:00.005357",
"end": "2023-08-30 16:05:18.620858",
"failed": false,
"invocation": {
"module_args": {
"_raw_params": "grep nginx /etc/passwd",
"_uses_shell": true,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"item": "nginx",
"rc": 0,
"start": "2023-08-30 16:05:18.615501",
"stderr": "",
"stderr_lines": [],
"stdout": "nginx:x:1000:1001::/home/nginx:/bin/bash",
"stdout_lines": [
"nginx:x:1000:1001::/home/nginx:/bin/bash"
]
}
]
}
}
TASK [show users.results] *************************************************************************************************
ok: [192.168.142.20] => {
"msg": [
{
"ansible_loop_var": "item",
"changed": true,
"cmd": "grep root /etc/passwd",
"delta": "0:00:00.003829",
"end": "2023-08-30 16:05:18.237586",
"failed": false,
"invocation": {
"module_args": {
"_raw_params": "grep root /etc/passwd",
"_uses_shell": true,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"item": "root",
"rc": 0,
"start": "2023-08-30 16:05:18.233757",
"stderr": "",
"stderr_lines": [],
"stdout": "root:x:0:0:root:/root:/bin/bash\noperator:x:11:0:operator:/root:/sbin/nologin",
"stdout_lines": [
"root:x:0:0:root:/root:/bin/bash",
"operator:x:11:0:operator:/root:/sbin/nologin"
]
},
{
"ansible_loop_var": "item",
"changed": true,
"cmd": "grep nginx /etc/passwd",
"delta": "0:00:00.005357",
"end": "2023-08-30 16:05:18.620858",
"failed": false,
"invocation": {
"module_args": {
"_raw_params": "grep nginx /etc/passwd",
"_uses_shell": true,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"item": "nginx",
"rc": 0,
"start": "2023-08-30 16:05:18.615501",
"stderr": "",
"stderr_lines": [],
"stdout": "nginx:x:1000:1001::/home/nginx:/bin/bash",
"stdout_lines": [
"nginx:x:1000:1001::/home/nginx:/bin/bash"
]
}
]
}
TASK [define userss by set_fact] ******************************************************************************************
ok: [192.168.142.20] => (item={'cmd': 'grep root /etc/passwd', 'stdout': 'root:x:0:0:root:/root:/bin/bash\noperator:x:11:0:operator:/root:/sbin/nologin', 'stderr': '', 'rc': 0, 'start': '2023-08-30 16:05:18.233757', 'end': '2023-08-30 16:05:18.237586', 'delta': '0:00:00.003829', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'grep root /etc/passwd', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['root:x:0:0:root:/root:/bin/bash', 'operator:x:11:0:operator:/root:/sbin/nologin'], 'stderr_lines': [], 'failed': False, 'item': 'root', 'ansible_loop_var': 'item'})
ok: [192.168.142.20] => (item={'cmd': 'grep nginx /etc/passwd', 'stdout': 'nginx:x:1000:1001::/home/nginx:/bin/bash', 'stderr': '', 'rc': 0, 'start': '2023-08-30 16:05:18.615501', 'end': '2023-08-30 16:05:18.620858', 'delta': '0:00:00.005357', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'grep nginx /etc/passwd', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['nginx:x:1000:1001::/home/nginx:/bin/bash'], 'stderr_lines': [], 'failed': False, 'item': 'nginx', 'ansible_loop_var': 'item'})
TASK [print userss] *******************************************************************************************************
ok: [192.168.142.20] => {
"msg": [
"root:x:0:0:root:/root:/bin/bash",
"operator:x:11:0:operator:/root:/sbin/nologin",
"nginx:x:1000:1001::/home/nginx:/bin/bash"
]
}
TASK [print userss one by one] ********************************************************************************************
ok: [192.168.142.20] => (item=root:x:0:0:root:/root:/bin/bash) => {
"msg": "root:x:0:0:root:/root:/bin/bash"
}
ok: [192.168.142.20] => (item=operator:x:11:0:operator:/root:/sbin/nologin) => {
"msg": "operator:x:11:0:operator:/root:/sbin/nologin"
}
ok: [192.168.142.20] => (item=nginx:x:1000:1001::/home/nginx:/bin/bash) => {
"msg": "nginx:x:1000:1001::/home/nginx:/bin/bash"
}
TASK [print part of userss one by one] ************************************************************************************
ok: [192.168.142.20] => (item=root:x:0:0:root:/root:/bin/bash) => {
"msg": "/bin/bash"
}
ok: [192.168.142.20] => (item=operator:x:11:0:operator:/root:/sbin/nologin) => {
"msg": "/sbin/nologin"
}
ok: [192.168.142.20] => (item=nginx:x:1000:1001::/home/nginx:/bin/bash) => {
"msg": "/bin/bash"
}
PLAY RECAP ****************************************************************************************************************
192.168.142.20 : ok=8 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
|