sandervanvugt

Ansible4H

Sep 14th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1. [root@control ~]# history
  2. 1 yum install python epel-release -y
  3. 2 yum install python38 epel-release -y
  4. 3 yum install -y ansible
  5. 4 vim /etc/hosts
  6. 5 ping ansible2
  7. 6 ping ansible1
  8. 7 exit
  9. 8 cat /etc/os-release
  10. 9 free -m
  11. 10 df -h
  12. 11 yum install -y vim bash-completion git
  13. 12 su - ansible
  14. 13 useradd ansible
  15. 14 passwd ansible
  16. 15 su - ansible
  17. 16 exit
  18. 17 history
  19.  
  20. #### config files
  21. [ansible@control install]$ cat makeuser.yml
  22. ---
  23. - name: create a user
  24. hosts: ansible2.example.com
  25. tasks:
  26. - name: create user
  27. user:
  28. name: linda
  29. state: present
  30. uid: 1010
  31. - name: print a dummy message
  32. debug:
  33. msg: hello everybody
  34.  
  35. #### config files[ansible@control loops]$ cat vardemo1.yaml
  36. ---
  37. - name: demonstrating variable use
  38. hosts: ansible1.example.com
  39. vars:
  40. user: linda
  41. tasks:
  42. - name: create user {{ user }}
  43. user:
  44. name: "{{ user }}"
  45. state: present
  46. - name: checking
  47. debug:
  48. msg: the user {{ user }} exists
  49.  
  50. [ansible@control base]$ cat un-ansible-loop.yml
  51. ---
  52. - name: clean up all
  53. hosts: all
  54. tasks:
  55. - name: remove services
  56. yum:
  57. name:
  58. - httpd
  59. - vsftpd
  60. state: absent
  61. - name: remove files
  62. file:
  63. path: "{{ item }}"
  64. state: absent
  65. loop:
  66. - /etc/ansible/facts.d
  67. - /var/www/html/index.html
  68. - /var/ftp/pub/README
  69. - /etc/motd
  70.  
  71. #####COMMAND
  72. [ansible@control base]$ history
  73. 1 git clone https://github.com/sandervanvugt/ansible-3h
  74. 2 cd ansible-3h/
  75. 3 ls
  76. 4 history
  77. 5 su -
  78. 6 ssh-keygen
  79. 7 ssh-copy-id ansible1
  80. 8 ssh-copy-id ansible2
  81. 9 ssh ansible1
  82. 10 ssh ansible2
  83. 11 pwd
  84. 12 ls
  85. 13 cd install/
  86. 14 ls
  87. 15 cat /etc/hosts
  88. 16 ls
  89. 17 pwd
  90. 18 vim inventory
  91. 19 vim ansible.cfg
  92. 20 ansible all -i inventory --list-hosts
  93. 21 ansible -m command -a "useradd bob"
  94. 22 ansible all -m command -a "useradd bob"
  95. 23 vim ansible.cfg
  96. 24 ansible --help
  97. 25 exit
  98. 26 history
  99. 27 ssh root@ansible1
  100. 28 ansible all -m command -a "useradd bob"
  101. 29 pwd
  102. 30 cd ansible-3h/install/
  103. 31 ansible all -m command -a "useradd bob"
  104. 32 vim ansible
  105. 33 ansible all -m raw -a "echo ansible ALL=(ALL) NOPASSWD:ALL > /etc/sudoers.d/ansible" -u root -k
  106. 34 ansible all -m raw -a 'echo ansible ALL=\(ALL\) NOPASSWD:ALL > /etc/sudoers.d/ansible' -u root -k
  107. 35 history
  108. 36 ansible all -m command -a "useradd bob"
  109. 37 history
  110. 38 cd ..
  111. 39 git clone https://github.com/sandervanvugt/luth
  112. 40 cd luth/
  113. 41 ./countdown 12
  114. 42 ansible ansible1.example.com -m command -a who
  115. 43 sudo vim /etc/ansible/hosts
  116. 44 su -
  117. 45 exit
  118. 46 id
  119. 47 sudo vim /etc/ansible/hosts
  120. 48 sudo vim /etc/ansible/ansible.cfg
  121. 49 cd ansible-3h/
  122. 50 cd install/
  123. 51 ansible ansible1.example.com -m command -a who
  124. 52 ansible ansible1.example.com -m shell -a who
  125. 53 ansible ansible1.example.com -m raw -a who
  126. 54 ansible ansible1.example.com -m command -a "rpm -qa | grep completion"
  127. 55 ansible ansible1.example.com -m shell -a "rpm -qa | grep completion"
  128. 56 ansible-doc -l | less
  129. 57 ansible-doc -l | wc
  130. 58 ansible -m command -a "useradd lisa"
  131. 59 ansible all -m command -a "useradd lisa"
  132. 60 ansible all -m user -a "name=lisa"
  133. 61 ansible all -m user -a "name=linda"
  134. 62 history
  135. 63 ansible-doc user
  136. 64 ansible all -m user -a "name=linda state=absent remove=yes"
  137. 65 vim vsftpd.yml
  138. 66 ansible-playbook vsftpd.yml
  139. 67 vim vsftpd.yml
  140. 68 ansible-playbook vsftpd.yml
  141. 69 vim vsftpd.yml
  142. 70 ansible-playbook vsftpd.yml
  143. 71 cd ..
  144. 72 ls
  145. 73 cd base
  146. 74 ls
  147. 75 cd ../ftp/
  148. 76 ls
  149. 77 cd ../install/
  150. 78 ls
  151. 79 vim makeuser.yml
  152. 80 ansible-playbook makeuser.yml
  153. 81 vim makeuser.yml
  154. 82 ansible-playbook makeuser.yml
  155. 83 history
  156. 84 ansible all -m user -a "name=linda state=absent remove=yes"
  157. 85 ansible-playbook makeuser.yml
  158. 86 vim makeuser.yml
  159. 87 vim ~/.vimrc
  160. 88 history
  161. 89 vim makeuser.yml
  162. 90 ansible-playbook makeuser.yml
  163. 91 ansible ansible2.example.com -a "tail /etc/passwd"
  164. 92 ansible ansible2.example.com -m setup | less
  165. 93 sleep 20; ~/luth/countdown 12
  166. 94 cat makeuser.yml
  167. 95 ansible ansible2.example.com -m setup > ../myfacts.txt
  168. 96 cd ..
  169. 97 less myfacts.txt
  170. 98 cd base
  171. 99 vim when-test.yml
  172. 100 ansible-playbook when-test.yml
  173. 101 vim inventory
  174. 102 vim when-test.yml
  175. 103 ansible-playbook when-test.yml
  176. 104 vim when-test.yml
  177. 105 ansible-playbook when-test.yml
  178. 106 vim when-test.yml
  179. 107 ls
  180. 108 cd ../install/
  181. 109 vim vsftpd.yml
  182. 110 ansible-playbook vsftpd.yml
  183. 111 cd ../base/
  184. 112 ls
  185. 113 cd ..
  186. 114 grep -R handler *
  187. 115 cd loops/
  188. 116 ls
  189. 117 vim handlers.yml
  190. 118 ansible-playbook handlers.yml
  191. 119 vim handlers.yml
  192. 120 touch /tmp/index.html
  193. 121 ansible-playbook handlers.yml
  194. 122 vim handlers.yml
  195. 123 ansible-playbook handlers.yml
  196. 124 ansible ansible1.example.com -m file -a "state=absent name=/var/www/html/index.html"
  197. 125 vim handlers.yml
  198. 126 ansible-playbook handlers.yml
  199. 127 vim handlers.yml
  200. 128 ansible ansible1.example.com -m file -a "state=absent name=/var/www/html/index.html"
  201. 129 ansible-playbook handlers.yml
  202. 130 ansible-playbook -vvvv handlers.yml
  203. 131 ls
  204. 132 cd ..
  205. 133 grep -r var *
  206. 134 ls
  207. 135 cd includes/
  208. 136 ls
  209. 137 cd ../includes/
  210. 138 ls
  211. 139 cd ../loops/
  212. 140 ls
  213. 141 vim vardemo1.yaml
  214. 142 cat vardemo1.yaml
  215. 143 ansible-playbook vardemo1.yaml
  216. 144 cat vardemo1.yaml
  217. 145 sleep 30; ~/luth/countdown 12
  218. 146 ansible-doc -l | grep jenkins
  219. 147 vim vardemo1.yaml
  220. 148 ansible-playbook vardemo1.yaml -e user=anna
  221. 149 vim vardemo1.yaml
  222. 150 ansible-playbook vardemo1.yaml -e user=anna
  223. 151 vim vardemo1.yaml
  224. 152 vim inventory
  225. 153 ansible-playbook vardemo1.yaml
  226. 154 vim inventory
  227. 155 ls
  228. 156 cd ..\
  229. 157 tree
  230. 158 ansible localhost -m yum -a "name=tree state=latest"
  231. 159 ansible localhost -m dnf -a "name=tree state=latest"
  232. 160 sudo yum install -y tree
  233. 161 cd ..
  234. 162 tree
  235. 163 cd loops/
  236. 164 mkdir group_vars
  237. 165 cd group_vars/
  238. 166 vim all
  239. 167 cd ..
  240. 168 vim inventory
  241. 169 ansible-playbook vardemo1.yaml
  242. 170 vim group_vars/all
  243. 171 ansible-playbook vardemo1.yaml
  244. 172 grep vars_ *
  245. 173 grep -R vars_ * ../
  246. 174 vim vardemo1.yaml
  247. 175 rm -rf group_vars/
  248. 176 mkdir vars
  249. 177 vim vars/users.yml
  250. 178 ansible-playbook vardemo1.yaml
  251. 179 vim register3.yml
  252. 180 ansible-playbook register3.yml
  253. 181 vim register3.yml
  254. 182 ansible-playbook register3.yml
  255. 183 cd ../..
  256. 184 git clone https://github.com/sandervanvugt/rhce8-book
  257. 185 cd rhce8-book/
  258. 186 ls
  259. 187 ls | wc
  260. 188* grep -l register *
  261. 189 vim listing728.yaml
  262. 190* vim listing8a.yaml
  263. 191 grep -e register -e when *
  264. 192 vim listing83.yaml
  265. 193 ansible-playbook listing83.yaml
  266. 194 cd ../ansible-3h/
  267. 195 cd includes/
  268. 196 vim site.yml
  269. 197 vim tasks/file.yml
  270. 198 ls
  271. 199 cd ../loops/
  272. 200 ls
  273. 201 cd ..
  274. 202 tree
  275. 203 cd base
  276. 204 ls
  277. 205 vim un-ansible.yml
  278. 206 vim un-ansible-loop.yml
  279. 207 cat un-ansible-loop.yml
  280. 208 ansible-playbook un-ansible
  281. 209 ansible-playbook un-ansible-loop.yml
  282. 210 history
Add Comment
Please, Sign In to add comment