Advertisement
sandervanvugt

ansible4h nov20

Nov 19th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.38 KB | None | 0 0
  1. [ansible@control install]$ cat setupuser.yaml
  2. ---
  3. - name: create a user and home environment
  4. hosts: all
  5. tasks:
  6. - name: create user
  7. command: useradd linda
  8. - name: copy file to user home
  9. copy:
  10. src: /etc/hosts
  11. dest: /home/linda
  12. [ansible@control install]$ cat setupuser2.yaml
  13. ---
  14. - name: create a user and home environment
  15. hosts: all
  16. tasks:
  17. - name: create user
  18. user:
  19. name: linda
  20. - name: copy file to user home
  21. copy:
  22. src: /etc/hosts
  23. dest: /home/linda
  24. [ansible@control install]$ cat installvim.yaml
  25. ---
  26. - name: install my favourite editor
  27. vars:
  28. myeditor: vim
  29. hosts: all
  30. tasks:
  31. - name: install {{ myeditor }}
  32. package:
  33. name: "{{ myeditor }}"
  34. [ansible@control base]$ cat greeter.yaml
  35. ---
  36. - name: test group vars
  37. hosts: file
  38. tasks:
  39. - debug:
  40. msg: the greeting is {{ greet }}
  41. [ansible@control base]$ tree group_vars/
  42. group_vars/
  43. └── file
  44.  
  45. 0 directories, 1 file
  46. [ansible@control base]$ cat group_vars/file
  47. greet: hello
  48. 1 su -
  49. 2 exit
  50. 3 id
  51. 4 sudo yum install epel-release -y
  52. 5 sudo yum install -y ansible
  53. 6 ansible --version
  54. 7 ssh-keygen
  55. 8 ssh-copy-id ansible1
  56. 9 sudo vim /etc/hosts
  57. 10 sudo vi /etc/hosts
  58. 11 ssh-copy-id ansible1
  59. 12 ssh ansible1
  60. 13 ssh-copy-id ansible2
  61. 14 mkdir install
  62. 15 cd install/
  63. 16 vi inventory
  64. 17 ansible all -i inventory --list-hosts
  65. 18 history
  66. 19 su -i
  67. 20 su -
  68. 21 vim inventory
  69. 22 vi inventory
  70. 23 cd ..
  71. 24 sudo yum install vim git -y
  72. 25 git clone https://github.com/sandervanvugt/ansible-4h
  73. 26 git clone https://github.com/sandervanvugt/ansible-3h
  74. 27 cd ansible-3h/
  75. 28 ls
  76. 29 cd install/
  77. 30 ls
  78. 31 cat inventory
  79. 32 cd ..
  80. 33 git clone https://github.com/sandervanvugt/luth
  81. 34 cd luth/
  82. 35 ls
  83. 36 ./countdown 12
  84. 37 cd ../ansible-3h/install/
  85. 38 ls
  86. 39 cat inventory
  87. 40 history
  88. 41 vim ansible.cfg
  89. 42 ansible all --list-hosts
  90. 43 ansible all -i ../../inventory --list-hosts
  91. 44 sudo vim /etc/ansible/hosts
  92. 45 ansible ansible1 -m command -a who
  93. 46 ping ansible1
  94. 47 vim inventory
  95. 48 ansible ansible1 -m command -a who
  96. 49 vim ansible.cfg
  97. 50 ssh ansible1
  98. 51 ansible ansible1 -m command -a who
  99. 52 ansible ansible1 -m command -a ls -l /root
  100. 53 ansible ansible1 -m command -a "ls -l /root"
  101. 54 sudo vim /etc/ansible/hosts
  102. 55 cd ..
  103. 56 ansible ansible1 -m command -a "ls -l /root"
  104. 57 cd install/
  105. 58 ansible all -m user -a "name=lisa"
  106. 59 ansible all -m comman -a "id lisa"
  107. 60 ansible all -m command -a "id lisa"
  108. 61 history | grep ansible
  109. 62 ansible-doc -l
  110. 63 ansible-doc -l | wc
  111. 64 ansible-doc -l
  112. 65 ansible-doc user
  113. 66 ansible all -m command -a "rpm -qa | grep vim"
  114. 67 ansible all -m shell -a "rpm -qa | grep vim"
  115. 68 history
  116. 69 vim vsftpd.yml
  117. 70 ansible-doc yum
  118. 71 ansible-doc copy
  119. 72 ansible-doc lineinfile
  120. 73 ansible-doc blockinfile
  121. 74 pwd
  122. 75 ../../luth/countdown 12
  123. 76 vim vsftpd.yml
  124. 77 ansible-playbook vsftpd.yml
  125. 78 vim vsftpd.yml
  126. 79 ansible-playbook vsftpd.yml
  127. 80 ssh ansbile2
  128. 81 ssh ansible2
  129. 82 ansible-playbook vsftpd.yml
  130. 83 vim setupuser.yaml
  131. 84 ansible-playbook setupuser.yaml
  132. 85 ansible all -m command -a "rm /home/linda/hosts"
  133. 86 ansible all -m file -a "name=/home/linda/hosts state=absent"
  134. 87 ansible-playbook setupuser.yaml
  135. 88 cp setupuser.yaml setupuser2.yaml
  136. 89 vim setupuser2.yaml
  137. 90 ansible-playbook setupuser2.yaml
  138. 91 cat setupuser.yaml
  139. 92 cat setupuser2.yaml
  140. 93 ssh ansible1
  141. 94 ssh ansible2
  142. 95 ansible-playbook vsftpd.yml
  143. 96 vim installvim.yaml
  144. 97 ansible-playbook installvim.yaml
  145. 98 vim installvim.yaml
  146. 99 ansible-playbook installvim.yaml
  147. 100 ls
  148. 101 cat installvim.yaml
  149. 102 cd ..
  150. 103 cd base/
  151. 104 ls
  152. 105 ansible all -m setup | less
  153. 106 ansible-doc -l | grep fact
  154. 107 ansible-doc -l | grep fact | less
  155. 108 ansible-doc -l package_facts
  156. 109 ansible-doc package_facts
  157. 110 ansible ansible1.example.com -m setup -a "filter=ansible_kernel"
  158. 111 ansible ansible1.example.com -m setup -a "filter=ansible_distribution"
  159. 112 ansible all -m setup | less
  160. 113 ansible ansible1.example.com -m setup -a "filter=ansible_default_ipv4"
  161. 114 ansible ansible1.example.com -m setup -a "filter=ansible_default_ipv4.address"
  162. 115 ansible all -m setup | less
  163. 116 ls
  164. 117 vim when-test.yml
  165. 118 ansible-playbook when-test.yml
  166. 119 pwd
  167. 120 ../../luth/countdown 12
  168. 121 vim when-test.yml
  169. 122 ansible-playbook when-test.yml
  170. 123 vim when-test.yml
  171. 124 ansible-playbook when-test.yml
  172. 125 vim when-test.yml
  173. 126 ansible-playbook when-test.yml
  174. 127 history | grep filter
  175. 128 ansible all -m setup -a "filter=ansible_default_ipv4"
  176. 129 ansible all -m setup -a "filter=ansible_facts['distribution']"
  177. 130 ansible all -m setup -a "filter=ansible_facts"
  178. 131 vim variables.yml
  179. 132 ansible-playbook variables.yml
  180. 133 vim when-test.yml
  181. 134 ls
  182. 135 cd ..
  183. 136 grep -r 'handler' *
  184. 137 cd loops/
  185. 138 ls
  186. 139 cd ..
  187. 140 sudo yum install -y tree
  188. 141 tree | less
  189. 142 cd ..
  190. 143 git clone https://github.com/sandervanvugt/rhce8-book
  191. 144 cd rhce8-book/
  192. 145 ls
  193. 146 ls | wc
  194. 147 cd host_vars/
  195. 148 ls
  196. 149 vim ansible1
  197. 150 cd ..
  198. 151 grep '{{ users' *
  199. 152 vim listing616.yaml
  200. 153 vim listing615.yaml
  201. 154 vim listing74.yaml
  202. 155 cd ../ansible-3h/
  203. 156 cd base
  204. 157 ls
  205. 158 cat inventory
  206. 159 vim inventory
  207. 160 mkdir group_vars
  208. 161 vim group_vars/file
  209. 162 vim greeter.yaml
  210. 163 ansible-playbook greeter.yaml
  211. 164 vim greeter.yaml
  212. 165 ansible-playbook greeter.yaml
  213. 166 vim group_vars/file
  214. 167 ansible-playbook greeter.yaml
  215. 168 cat greeter.yaml
  216. 169 tree group_vars/
  217. 170 cat group_vars/file
  218. 171 cd ..
  219. 172 grep -r 'register' *
  220. 173 cd loops/
  221. 174 vim register.yml
  222. 175 vim register2.yml
  223. 176 ansible-playbook register2.yml
  224. 177 vim register2.yml
  225. 178 ansible-playbook register2.yml
  226. 179 vim register2.yml
  227. 180 ansible-playbook register2.yml
  228. 181 vim register2.yml
  229. 182 history
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement