Advertisement
sandervanvugt

RHCE day2 may22

May 17th, 2022
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.49 KB | None | 0 0
  1. [ansible@control lesson5]$ cat variables_example.yaml
  2. ---
  3. - name: variables test
  4. vars:
  5. myuser: linda
  6. hosts: ansible1.example.com
  7. tasks:
  8. - name: defining user {{ myuser }}
  9. debug:
  10. msg: creating {{ myuser }}
  11. - name: doing it
  12. user:
  13. name: "{{ myuser }}"
  14.  
  15. [ansible@control lesson5]$ cat askme.yaml
  16. ---
  17. - name: ask me anything
  18. vars_prompt:
  19. - name: my_answer
  20. prompt: which package do you want to install
  21. private: no
  22. hosts: all
  23. tasks:
  24. - debug:
  25. msg: the answer is {{ my_answer }}
  26.  
  27. ---
  28. - name: create user
  29. vars:
  30. myuser: bill
  31. mygroups: sales
  32. hosts: ansible1.example.com
  33. tasks:
  34. - name: adding groups
  35. group:
  36. name: "{{ mygroups }}"
  37. - name: creating users
  38. user:
  39. name: "{{ myuser }}"
  40. groups: "{{ mygroups }}"
  41.  
  42. [ansible@control facts]$ cat printfacts.yaml
  43. ---
  44. - name: print the facts about the facgts
  45. hosts: ansible2
  46. tasks:
  47. - debug:
  48. msg: the package is {{ ansible_facts.ansible_local.localfacts['myfacts']['package'] }}
  49.  
  50.  
  51.  
  52. [ansible@control lesson8]$ history
  53. 1 ip a
  54. 2 sudo vim /etc/hosts
  55. 3 ping ansible1
  56. 4 sudo vim /etc/hosts
  57. 5 ping ansible1
  58. 6 ping ansible2
  59. 7 ping ansible3
  60. 8 sudo yum install -y epel-release
  61. 9 sudo yum install ansible
  62. 10 sudo yum update -y
  63. 11 sudo yum install ansible
  64. 12 sudo reboot
  65. 13 sudo yum install ansible
  66. 14 sudo yum provides */sshpass
  67. 15 sudo yum install ansible --nobest
  68. 16 sudo yum install ansible --skip-broken
  69. 17 sudo -i
  70. 18 sudo yum install ansible
  71. 19 sudo vim /etc/yum.repos.d/oldepel.repo
  72. 20 sudo cat /etc/yum.repos.d/oldepel.repo
  73. 21 ansible --version
  74. 22 ping ansible1
  75. 23 mkdir setup
  76. 24 cd setup
  77. 25 vim inventory
  78. 26 ansible -i inventory all -m ping
  79. 27 ssh root@ansible1
  80. 28 ssh root@ansible2
  81. 29 ssh root@ansible3
  82. 30 ansible -i inventory all -m ping
  83. 31 ansible -i inventory all -m ping -u root -k
  84. 32 history
  85. 33 ansible -i inventory all -u root -k -m command -a "useradd ansible"
  86. 34 sudo useradd ansible
  87. 35 echo $?
  88. 36 ansible -i inventory all -u root -k -m user -a "name=ansible"
  89. 37 ansible -i inventory all -u root -k -m user -a "name=bob"
  90. 38 history
  91. 39 ansible -i inventory all -u root -k -m shell -a "echo password | passwd --stdin ansible"
  92. 40 ssh ansible@ansible1
  93. 41 history
  94. 42 ansible -i inventory all -u ansible -k -m command -a "whoami"
  95. 43 ansible -i inventory all -u ansible -k -m command -a "ls -l /root"
  96. 44 ansible -i inventory all -u root -k -m shell -a '"ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ansible'
  97. 45 ansible -i inventory all -u root -k -m shell -a 'echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ansible'
  98. 46 ssh ansible1
  99. 47 ansible -i inventory all -u ansible -k -m command -a "ls -l /root"
  100. 48 ansible -i inventory all -u ansible -k -b -m command -a "ls -l /root"
  101. 49 ssh-keygen
  102. 50 ssh-copy-id ansible1
  103. 51 ssh-copy-id ansible2
  104. 52 ssh-copy-id ansible3
  105. 53 ssh ansible3
  106. 54 ansible -i inventory all -u ansible -b -m command -a "ls -l /root"
  107. 55 history
  108. 56 pwd
  109. 57 vim inventory
  110. 58 sudo vim /etc/ansible/hosts
  111. 59 ansible --version
  112. 60 ansible -i inventory all --list-hosts
  113. 61 ansible db --list-hosts
  114. 62 ansible -i inventory db --list-hosts
  115. 63 history
  116. 64 sudo vim /etc/ansible/ansible.cfg
  117. 65 ansible --version
  118. 66 vim ansible.cfg
  119. 67 ansible --version
  120. 68 cd ..
  121. 69 sudo yum install git
  122. 70 git clone https://github.com/sandervanvugt/rhce8-live
  123. 71 ls
  124. 72 cd rhce8-live/
  125. 73 ls
  126. 74 cd lesson2/
  127. 75 ls
  128. 76 vim ansible.cfg
  129. 77 vim inventory
  130. 78 ansible all -m command -a "ls -l /root"
  131. 79 history
  132. 80 ansible-doc -l |wc
  133. 81 ansible-doc -l
  134. 82 ansible-doc user
  135. 83 ansible all -m service -a "name=httpd state=started"
  136. 84 ansible all -m service -a "name=crond state=started"
  137. 85 ansible all -m service -a "name=crond state=stopped"
  138. 86 ansible all -m command -a "/sbin/reboot -t now"
  139. 87 ansible all -m command -a "/sbin/reboot"
  140. 88 ansible all -m service -a "name=crond state=started"
  141. 89 cd
  142. 90 ansible all -m ping
  143. 91 ls
  144. 92 ansible all -m ping -i setup/inventory
  145. 93 cd rhce8-live/
  146. 94 ls
  147. 95 ./countdown 14
  148. 96 cd lesson2/
  149. 97 ansible all -m package -a "name=nmap"
  150. 98 ansible-doc yum
  151. 99 ansible all -m service -a "name=httpd state=started"
  152. 100 yum demostructure.yaml
  153. 101 vim demostructure.yaml
  154. 102 ansible-playbook demostructure.yaml
  155. 103 vim demostructure.yaml
  156. 104 ansible-playbook demostructure.yaml
  157. 105 cat demostructure.yaml
  158. 106 vim demostructure.yaml
  159. 107 ansible-playbook demostructure.yaml
  160. 108 vim demostructure.yaml
  161. 109 ansible-playbook demostructure.yaml
  162. 110 vim demostructure.yaml
  163. 111 ansible-playbook demostructure.yaml
  164. 112 vim demostructure.yaml
  165. 113 vim ~/.vimrc
  166. 114 ls
  167. 115 cd ../lesson5
  168. 116 ls
  169. 117 grep vsftp *
  170. 118 cd ..
  171. 119 ls
  172. 120 cd lesson4
  173. 121 ls
  174. 122 vim vsftpd.yml
  175. 123 ansible-playbook vsftpd.yml
  176. 124 history
  177. 125 ansible-playbook vsftpd.yml
  178. 126 sudo vim /etc/hosts
  179. 127 ansible-doc copy
  180. 128 ansible all -m copy -a "src=/etc/hosts dest=/etc/hosts"
  181. 129 ansible-playbook vsftpd.yml
  182. 130 history
  183. 131 vim ansible.cfg
  184. 132 ansible-playbook vsftpd-err.yml
  185. 133 vim vsftpd-err.yml
  186. 134 ansible-playbook vsftpd-err.yml
  187. 135 ansible-playbook --syntax-check vsftpd-err.yml
  188. 136 ansible-playbook -v vsftpd.yml
  189. 137 ansible-playbook -vvvv vsftpd.yml
  190. 138 sudo yum provides */ansible-lint
  191. 139 sudo yum install -y python3-ansible-lint
  192. 140 ansible-lint -L
  193. 141 ansible-lint vsftpd.yml
  194. 142 ansible all -m setup | less
  195. 143 cd ../lesson5/
  196. 144 vim inventory
  197. 145 ls
  198. 146 cd ../lesson4/
  199. 147 ls
  200. 148 cd ..
  201. 149 cd lesson7/
  202. 150 ls
  203. 151 cd
  204. 152 find -name "variables_example.*"
  205. 153 cd rhce8-live/
  206. 154 cd lesson5/
  207. 155 ls
  208. 156 vim variables_example.yaml
  209. 157 ansible-playbook variables_example.yaml
  210. 158 vim variables_example.yaml
  211. 159 ansible-playbook variables_example.yaml
  212. 160 vim variables_example.yaml
  213. 161 ansible-playbook variables_example.yaml -e myuser=bob
  214. 162 cat variables_example.yaml
  215. 163 find ~ -name "variables_example.*"
  216. 164 ls
  217. 165 cd ../..
  218. 166 git clone https://github.com/sandervanvugt/rhce8
  219. 167 git clone https://github.com/sandervanvugt/rhce8-book
  220. 168 find ~ -name "variables_example.*"
  221. 169 vim askme.yaml
  222. 170 cd rhce8-book/
  223. 171 grep vars_prompt
  224. 172 grep vars_prompt *
  225. 173 vim listing710.yaml
  226. 174 cd -
  227. 175 vim askme.yaml
  228. 176 vim rhce8-book/listing710.yaml
  229. 177 vim askme.yaml
  230. 178 ansible-playbook askme.yaml
  231. 179 mv askme.yaml rhce8-live/lesson5/
  232. 180 cd rhce8-live/lesson5/
  233. 181 ls
  234. 182 ansible-playbook askme.yaml
  235. 183 vim inventory
  236. 184 vim askme.yaml
  237. 185 ansible-playbook askme.yaml
  238. 186 cat askme.yaml
  239. 187 ls
  240. 188 cd webservers/
  241. 189 ls
  242. 190 pwd
  243. 191 ls
  244. 192 cat inventory
  245. 193 tree
  246. 194 vim group_vars/lamp
  247. 195 vim site.yml
  248. 196 ansible-playbook site.yml
  249. 197 history
  250. 198 cd ..
  251. 199 vim create_user.yaml
  252. 200 ansible-playbook create_user.yaml
  253. 201 vim create_user.yaml
  254. 202 ansible-playbook create_user.yaml
  255. 203 vim create_user.yaml
  256. 204 ansible-playbook create_user.yaml
  257. 205 ansible-doc -l | grep group
  258. 206 ansible-doc group
  259. 207 vim create_user.yaml
  260. 208 ansible-playbook create_user.yaml
  261. 209 cat create_user.yaml
  262. 210 ../countdown 12
  263. 211 vim ct.yaml
  264. 212 ansible -u root - inventory remotehost -k -m raw -a "yum install -y python3"
  265. 213 ansible -u root -i inventory remotehost -k -m raw -a "yum install -y python3"
  266. 214 ansible-vault --help
  267. 215 cd ../lesson7/
  268. 216 ls
  269. 217 cd vault/
  270. 218 ls
  271. 219 ansible-vault create secret.yml
  272. 220 cat secret.yml
  273. 221 vim create-user.yml
  274. 222 ansible-playbook create-user.yml
  275. 223 ansible-playbook --ask-vault-pass create-user.yml
  276. 224 ansible ansible1.example.com -a "tail /etc/shadow"
  277. 225 echo password > ~/vault-pass
  278. 226 ansible-playbook --vault-password-file=~/vault-pass create-user.yml
  279. 227 history
  280. 228 vim secret.dummy
  281. 229 cat secret.dummy
  282. 230 cat create-user.yml
  283. 231 ansible ansible1.example.com -m setup | less
  284. 232 history | grep copy
  285. 233 cd ..
  286. 234 pwd
  287. 235 cd facts/
  288. 236 ls
  289. 237 vim facts.yml
  290. 238 ansible-playbook facts.yml
  291. 239 vim ansible.cfg
  292. 240 ansible-playbook facts.yml
  293. 241 vim inventory
  294. 242 ansible-playbook facts.yml
  295. 243 vim ipfact.yml
  296. 244 ansible-playbook ipfact.yml
  297. 245 vim ipfact.yml
  298. 246 pwd
  299. 247 ../../countdown 13
  300. 248 vim ipfact.yml
  301. 249 ls
  302. 250 vim newlocalfacts.yml
  303. 251 vim localfacts.fact
  304. 252 ansible-playbook newlocalfacts.yml
  305. 253 vim inventory
  306. 254 ansible-playbook newlocalfacts.yml
  307. 255 ansible ansible2 -m setup -a "filter=ansible_local"
  308. 256 vim printfacts.yaml
  309. 257 ansible-playbook printfacts.yaml
  310. 258 vim printfacts.yaml
  311. 259 ansible-playbook printfacts.yaml
  312. 260 vim printfacts.yaml
  313. 261 ansible-playbook printfacts.yaml
  314. 262 vim printfacts.yaml
  315. 263 ansible-playbook printfacts.yaml
  316. 264 vim printfacts.yaml
  317. 265 cat printfacts.yaml
  318. 266 ls
  319. 267 vim setupfactcache.yaml
  320. 268 ansible -m setup ansible2
  321. 269 ansible -m setup ansible2 | less
  322. 270 cd ..
  323. 271 ls
  324. 272 cd arrays/
  325. 273 ls
  326. 274 vim inventory
  327. 275 tree
  328. 276 cat vars/users-dictionary
  329. 277 cat vars/users-list
  330. 278 ls
  331. 279 vim multi-list.yml
  332. 280 ansible-playbook multi-list.yml
  333. 281 ansible-playbook multi-dictionary.yml
  334. 282 vim multi-dictionary.yml
  335. 283 ls
  336. 284 pwd
  337. 285 ../../countdown 13
  338. 286 cd ..
  339. 287 ls
  340. 288 cd lesson8/
  341. 289 ls
  342. 290 vim loopservices.yml
  343. 291 ansible-playbook loopservices.yml
  344. 292 vim loopservices.yml
  345. 293 ansible-playbook loopservices.yml
  346. 294 vim loopusers.yml
  347. 295 ansible-playbook loopusers.yml
  348. 296 vim loop-over-variable.yml
  349. 297 cat loopvars.yml
  350. 298 vim loop-over-variable.yml
  351. 299 ansible-playbook loop-over-variable.yml
  352. 300 ls
  353. 301 vim register_loop.yml
  354. 302 ansible-playbook register_loop.yml
  355. 303 im register_command.yml
  356. 304 vim register_command.yml
  357. 305 vim register_loop.yml
  358. 306 ansible-playbook register_loop.yml
  359. 307 vim register_loop.yml
  360. 308 ansible-playbook register_loop.yml
  361. 309 vim register_loop.yml
  362. 310 ansible-playbook register_loop.yml
  363. 311 vim register_loop.yml
  364. 312 ansible-playbook register_loop.yml
  365. 313 vim register_command.yml
  366. 314 ansible-playbook register_command.yml
  367. 315 vim register_command.yml
  368. 316 ansible-playbook register_command.yml
  369. 317 vim register_command.yml
  370. 318 vim distro.yml
  371. 319 ansible-playbook distro.yml
  372. 320 vim distro.yml
  373. 321 ansible-playbook distro.yml
  374. 322 vim distro.yml
  375. 323 vim distro.yml -e mypackage=vsftpd
  376. 324 ansible-playbook distro.yml -e mypackage=vsftpd
  377. 325 vim quicktest.yml
  378. 326 ansible-playbook quicktest.yml
  379. 327 vim quicktest.yml
  380. 328 ansible-playbook quicktest.yml
  381. 329 vim command-output-test.yml
  382. 330 vgs
  383. 331 sudo vgs
  384. 332 ansible-playbook command-output-test.yml
  385. 333 vim command-output-test.yml
  386. 334 history
  387.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement