sandervanvugt

RHCE oct20 day2

Oct 6th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.19 KB | None | 0 0
  1. ##### EXAMPLE OF FACTS NOTATIONS
  2. ---
  3. - hosts: all
  4. tasks:
  5. - name: show IP address
  6. debug:
  7. msg: >
  8. This host uses IP address {{ ansible_facts.default_ipv4.address }}
  9. - name: show IP address once more
  10. debug:
  11. msg: The IP address is {{ ansible_facts['default_ipv4']['address'] }}
  12. - name: old notation this time
  13. debug:
  14. msg: The IP address is {{ ansible_default_ipv4.address }}
  15. - name: old notation a bit less old
  16. debug:
  17. msg: The IP address is {{ ansible_default_ipv4['address'] }}
  18.  
  19. #####
  20. [ansible@control lesson8]$ history
  21. 1 ssh-keygen
  22. 2 ssh-copy-id ansible1
  23. 3 ssh-copy-id ansible2
  24. 4 history
  25. 5 ansible --version
  26. 6 git clone https://github.com/sandervanvugt/rhce8-live
  27. 7 git clone https://github.com/sandervanvugt/rhce8-book
  28. 8 ls
  29. 9 cd rhce8-live/
  30. 10 ls
  31. 11 ./countdown 12
  32. 12 sudo vim /etc/ansible/hosts
  33. 13 sudo vim /etc/ansible/ansible.cfg
  34. 14 ansible -i inventory all --list-hosts
  35. 15 ls
  36. 16 cd lesson2/
  37. 17 ls
  38. 18 cat inventory
  39. 19 ansible -i inventory all --list-hosts
  40. 20 ansible web --list-hosts
  41. 21 ansible -i inventory ungrouped --list-hosts
  42. 22 vim ansible.cfg
  43. 23 ls
  44. 24 ls -l
  45. 25 mv inventory /tmp
  46. 26 mkdir inventory
  47. 27 mv /tmp/inventory inventory/
  48. 28 grep inventory ansible.cfg
  49. 29 ansible --version
  50. 30 ansible all -m user -a "name=lisa"
  51. 31 ansible all -m command -a "id lisa"
  52. 32 ansible -m command -a "useradd lisa"
  53. 33 ansible all -m command -a "useradd lisa"
  54. 34 ansible all -m user -a "name=lisa"
  55. 35 history
  56. 36 ansible ansible1.example.com -m command -a "rpm -qa | grep nmap"
  57. 37 ansible ansible1.example.com -m shell -a "rpm -qa | grep nmap"
  58. 38 ansible all -m ping
  59. 39 ansible all -m service -a "name=httpd state=started"
  60. 40 ansible all -m copy -a 'content="hello world" dest=/etc/motd"
  61. 41 ansible all -m copy -a 'content="hello world" dest=/etc/motd'
  62. 42 ansible all -a "cat /etc/motd"
  63. 43 history
  64. 44 ../countdown 12
  65. 45 vim inventory/
  66. 46 history
  67. 47 ansible all -a "cat /etc/motd"
  68. 48 ansible-doc -l
  69. 49 ansible-doc -l | wc
  70. 50 ansible-doc -l | grep '^ios'
  71. 51 ansible-doc -l | grep '^ios' | wc
  72. 52 ansible-doc user
  73. 53 ansible -u root -i inventory ansible2.example.com --ask-pass -m raw -a "yum install -y python3"
  74. 54 vim ~/.vimrc
  75. 55 cd ../lesson4/
  76. 56 ls
  77. 57 vim vsftpd.yml
  78. 58 vim ~/.vimrc
  79. 59 vim vsftpd.yml
  80. 60 ansible-playbook vsftpd.yml
  81. 61 vim vsftpd.yml
  82. 62 ansible-playbook vsftpd.yml
  83. 63 vim vsftpd.yml
  84. 64 ansible-playbook vsftpd.yml
  85. 65 vim vsftpd.yml
  86. 66 ansible-playbook vsftpd.yml
  87. 67 ansible-playbook --syantax-check vsftpd.yml
  88. 68 ansible-playbook vsftpd.yml --syntax-check
  89. 69 vim vsftpd.yml
  90. 70 ansible-playbook -v vsftpd.yml
  91. 71 ansible-playbook -vvvv vsftpd.yml
  92. 72 vim web-setup-and-test.yml
  93. 73 ansible-playbook web-setup-and-test.yml
  94. 74 ../countdown 12
  95. 75 ansible ansible1.example.com -m setup > ../lesson5/facts.txt
  96. 76 cd ../lesson5/
  97. 77 less facts.txt
  98. 78 ansible-doc -l | grep facts | less
  99. 79 ansible-doc -l | grep facts | wc
  100. 80 ls
  101. 81 vim user.yml
  102. 82 ansible-playbook user.yml
  103. 83 ansible-playbook --help
  104. 84 ansible-playbook user.yml -e user=anna
  105. 85 vim user.yml
  106. 86 ansible-playbook user.yml
  107. 87 vim user.yml
  108. 88 ansible-playbook user.yml
  109. 89 ls
  110. 90 history | grep git
  111. 91 cd webservers/
  112. 92 ls
  113. 93 cat inventory
  114. 94 cat ansible.cfg
  115. 95 ls group_vars/
  116. 96 cat inventory
  117. 97 ls
  118. 98 cat group_vars/lamp
  119. 99 vim site.yml
  120. 100 ansible-playbook site.yml
  121. 101 history
  122. 102 vim site.yml
  123. 103 ansible-playbook --dry-run site.yml
  124. 104 ansible-playbook -C site.yml
  125. 105 exit
  126. 106 pwd
  127. 107 ls
  128. 108 cd rhce8-live/
  129. 109 cd lesson5/
  130. 110 ls
  131. 111 cd webservers/
  132. 112 ls
  133. 113 ls group_vars/
  134. 114 cat inventory
  135. 115 cat group_vars/lamp
  136. 116 vim site.yml
  137. 117 vim cob.yml
  138. 118 ansible-playbook cob.yml
  139. 119 vim gary.yaml
  140. 120 ansible-playbook gary.yaml
  141. 121 ansible -u root -i inventory ansible2.example.com --ask-pass -m raw -a "yum install -y python3"
  142. 122 ansible-doc yum
  143. 123 vim cob.yml
  144. 124 ansible-vault -h
  145. 125 pwd
  146. 126 cd ../../lesson7/
  147. 127 ls
  148. 128 cd vault/
  149. 129 ls
  150. 130 ansible-vault create secret.yml
  151. 131 cat secret.yml
  152. 132 vim create-user.yml
  153. 133 ansible-playbook create-user.yml
  154. 134 ansible-playbook --ask-vault-pass create-user.yml
  155. 135 ansible ansible1.example.com -a "tail /etc/shadow"
  156. 136 echo password > vault-pass
  157. 137 ls -l vault-pass
  158. 138 ansible-playbook --vault-password-file=vault-pass create-users.yml
  159. 139 ls
  160. 140 ansible-playbook --vault-password-file=vault-pass create-user.yml
  161. 141 vim create-user.yml
  162. 142 ls
  163. 143 vim create-user.yml
  164. 144 rm secret.yml
  165. 145 vim secret.yml
  166. 146 vim create-user.yml
  167. 147 vim password.yml
  168. 148 rm secret.yml
  169. 149 rm create-user.yml
  170. 150 ansible-vault create secret.yml
  171. 151 vim password.yml
  172. 152 ansible-vault encrypt password.yml
  173. 153 ls
  174. 154 vim create-users.yml
  175. 155 ansible-playbook --vault-id @prompt create-users.yml
  176. 156 vim create-users.yml
  177. 157 ansible-playbook --vault-id @prompt create-users.yml
  178. 158 cd ..
  179. 159 ansible -m setup all
  180. 160 ls
  181. 161 cd facts/
  182. 162 ansible -m setup all
  183. 163 ansible -m setup all > facts.txt
  184. 164 less facts.txt
  185. 165 ls
  186. 166 vim facts.yml
  187. 167 ansible-playbook facts.yml
  188. 168 ls
  189. 169 vim ipfact.yml
  190. 170 ansible-playbook ipfact.yml
  191. 171 vim ipfact.yml
  192. 172 vim facts.txt
  193. 173 vim ipfact.yml
  194. 174 vim facts.txt
  195. 175 pwd
  196. 176 ../../countdown 12
  197. 177 cd ../vault/
  198. 178 ls
  199. 179 cat password.yml
  200. 180 cat secret.yml
  201. 181 cat create-users.yml
  202. 182 ansible-playbook --vault-id username@prompt pwhash@prompt create-users.yml
  203. 183 ansible-playbook --vault-id username@prompt --vault-id pwhash@prompt create-users.yml
  204. 184 vim create-users.yml
  205. 185 ansible-playbook --vault-id username@prompt --vault-id pwhash@prompt create-users.yml
  206. 186 cd ../facts/
  207. 187 vim ipfact.yml
  208. 188 ansible-playbook ipfact.yml
  209. 189 vim ipfact.yml
  210. 190 pwd
  211. 191 ls
  212. 192 vim newlocalfacts.yml
  213. 193 vim localfacts.fact
  214. 194 ansible-playbook newlocalfacts.yml
  215. 195 ansible ansible1.example.com -m setup -a "filter=ansible_local"
  216. 196 vim localfacts.fact
  217. 197 echo ansible_facts.local.localfacts.localfacts.package >> newlocalfacts.yml
  218. 198 vim newlocalfacts.yml
  219. 199 ansible-doc debug
  220. 200 vim newlocalfacts.yml
  221. 201 ansible-playbook newlocalfacts.yml
  222. 202 vim newlocalfacts.yml
  223. 203 ansible ansible1.example.com -m setup -a "filter=ansible_facts.local"
  224. 204 ansible ansible1.example.com -m setup -a "filter=ansible_local"
  225. 205 vim newlocalfacts.yml
  226. 206 ansible ansible1.example.com -m setup -a "filter=ansible_local"
  227. 207 ansible-playbook newlocalfacts.yml
  228. 208 vim newlocalfacts.yml
  229. 209 ansible-playbook newlocalfacts.yml
  230. 210 vim newlocalfacts.yml
  231. 211 ansible-doc | grep facts | grep pack
  232. 212 ansible-doc -l | grep facts | grep pack
  233. 213 cd ..
  234. 214 git clone https://github.com/sandervanvugt/ansible-advanced
  235. 215 cd ansible-advanced/
  236. 216 ls
  237. 217 cd windows/
  238. 218 ls
  239. 219 cat ansible.cfg
  240. 220 cat inventory
  241. 221 d ../..
  242. 222 cd ../../rhce8-live/
  243. 223 ls
  244. 224 cd lesson7/
  245. 225 ls
  246. 226 cd arrays/
  247. 227 ls
  248. 228 cat vars/users-dictionary
  249. 229 cat vars/users-list
  250. 230 vim multi-list.yml
  251. 231 ansible-playbook multi-list.yml
  252. 232 vim multi-dictionary.yml
  253. 233 ansible-playbook multi-dictionary.yml
  254. 234 pwd
  255. 235 ../../countdown 12
  256. 236 cd ../../lesson8/
  257. 237 ls
  258. 238 cat loopservices.yml
  259. 239 vim loopservices.yml
  260. 240 ansible-playbook loopservices.yml
  261. 241 vim loopusers.yml
  262. 242 ansible-playbook loopusers.yml
  263. 243 vim loopusers.yml
  264. 244 ansible-playbook loopusers.yml
  265. 245 vim loopusers.yml
  266. 246 vim loopservices.yml
  267. 247 vim loop-over-variable.yml
  268. 248 vim loopvars.yml
  269. 249 ansible-playbook loop-over-variable.yml
  270. 250 vim register_loop.yml
  271. 251 ansible-playbook register_loop.yml
  272. 252 vim register_command.yml
  273. 253 ansible-playbook register_command.yml
  274. 254 vim register_command.yml
  275. 255 ansible-playbook register_command.yml
  276. 256 ls
  277. 257 vim distro.yml
  278. 258 ansible-playbook distro.yml
  279. 259 vim distro.yml
  280. 260 ansible-playbook distro.yml
  281. 261 vim distro.yml
  282. 262 ansible-playbook distro.yml -e mypackage=tmux
  283. 263 ls
  284. 264 vim quicktest.yml
  285. 265 ansible-playbook quicktest.yml
  286. 266 vim quicktest.yml
  287. 267 ansible-playbook quicktest.yml
  288. 268 vim command-output-test.yml
  289. 269 ansible-playbook command-output-test.yml
  290. 270 vim command-output-test.yml
  291. 271 ansible-playbook command-output-test.yml
  292. 272 cat command-output-test.yml
  293. 273 sudo yum install vdo
  294. 274 less /usr/share/doc/vdo/examples/ansible/test_vdocreate.yml
  295. 275 pwd
  296. 276 ../countdown 12
  297. 277 ls
  298. 278 vim when_multiple.yml
  299. 279 ansible-playbook when_multiple.yml
  300. 280 vim when_multiple.yml
  301. 281 ansible-playbook when_multiple.yml
  302. 282 vim when_multiple_complex.yml
  303. 283 ansible-playbook when_multiple_complex.yml
  304. 284 vim restart.yml
  305. 285 ansible-playbook restart.yml
  306. 286 ls
  307. 287 vim ifsize.yml
  308. 288 ls ../lesson5/
  309. 289 less ../lesson5/facts.txt
  310. 290 vim ifsize.yml
  311. 291 ansible-playbook ifsize.yml -vv
  312. 292 vim ifsize.yml
  313. 293 ansible-playbook ifsize.yml -vv
  314. 294 vim handlers.yml
  315. 295 ansible-playbook handlers.yml
  316. 296 touch /tmp/index.html
  317. 297 ansible-playbook handlers.yml
  318. 298 vim handlers.yml
  319. 299 ansible-playbook handlers.yml
  320. 300 ansible all -m file -a "name=/var/www/html/index.html state=absent"
  321. 301 ansible-playbook handlers.yml
  322. 302 history
  323. 303 vim blocks.yml
  324. 304 ansible-playbook blocks.yml
  325. 305 vim blocks2.yml
  326. 306 ansible-playbook blocks2.yml
  327. 307 history
Add Comment
Please, Sign In to add comment