sandervanvugt

ansibleinthreeweeks day1 dec21

Dec 3rd, 2021
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.69 KB | None | 0 0
  1. [ansible@control basics]$ cat new_facts.yaml
  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 adress - new and deprecated
  10. debug:
  11. msg: This host uses IP address {{ ansible_facts.default_ipv4.address }}
  12. - name: again - old notation one
  13. debug:
  14. msg: This host uses {{ ansible_default_ipv4['address'] }}
  15. - name: again - old an soooo deprecated
  16. debug:
  17. msg: This host uses {{ ansible_default_ipv4.address }}
  18.  
  19. *******[ansible@control basics]$ history
  20. 1 ip a
  21. 2 sudo vi /etc/hosts
  22. 3 cat /etc/hosts
  23. 4 sudo dnf install epel -y
  24. 5 sudo dnf install epel-release -y
  25. 6 sudo dnf install -y ansible
  26. 7 vim inventory
  27. 8 ping rocky
  28. 9 ping ubuntu
  29. 10 sudo vi /etc/hosts
  30. 11 ping ubuntu
  31. 12 ansible --version
  32. 13 sudo dnf install git -y
  33. 14 git clone https://github.com/sandervanvugt/ansibleinthreeweeks
  34. 15 cd ansibleinthreeweeks/
  35. 16 ls
  36. 17 git pull
  37. 18 ./countdown 12
  38. 19 sudo sh -c "echo password | passwd --stdin ansible"
  39. 20 echo ansible ALL=(ALL) NOPASSWD: ALL >/tmp/sudoers
  40. 21 echo "ansible ALL=(ALL) NOPASSWD: ALL" >/tmp/sudoers
  41. 22 cd ..
  42. 23 cat inventory
  43. 24 ansible rocky -i inventory -u root -k -m raw -a "useradd -G wheel ansible"
  44. 25 ssh root@rocky
  45. 26 ansible rocky -i inventory -u root -k -m raw -a "useradd -G wheel ansible"
  46. 27 ansible rocky -i inventory -u root -k -m command -a "id"
  47. 28 ansible rocky -i inventory -u root -k -m command -a "id ansible"
  48. 29 history
  49. 30 ansible rocky -i inventory -u root -k -m shell -a "echo password | passwd --stdin ansible"
  50. 31 ssh ansible@rocky
  51. 32 ansible rocky -i inventory -u root -k -m copy -a "src=/tmp/sudoers dest=/etc/sudoers.d/ansible"
  52. 33 ansible rocky -u ansible -k -i inventory -m command -a "ls -l /root"
  53. 34 ansible rocky -u ansible -k -i inventory -b -m command -a "ls -l /root"
  54. 35 ssh-keygen
  55. 36 ssh-copy-id rocky
  56. 37 ansible rocky -u ansible -i inventory -b -m command -a "ls -l /root"
  57. 38 history
  58. 39 #ansible ubuntu -i inventory -u student -k -b -K -m command -a "useradd -G sudo ansible"
  59. 40 ssh student@ubuntu
  60. 41 #ansible ubuntu -i inventory -u student -k -b -K -m command -a "useradd -m -G sudo ansible"
  61. 42 ansible ubuntu -i inventory -u student -k -b -K -m command -a "useradd -m -G sudo ansible"
  62. 43 ansible ubuntu -i inventory -u ansible -k -b -K -m command -a "ls /root"
  63. 44 ansible ubuntu -i inventory -u student -k -b -K -m shell -a "echo ansible:password | chpasswd"
  64. 45 ansible ubuntu -i inventory -u ansible -k -b -K -m command -a "ls /root"
  65. 46 ansible ubuntu -i inventory -u ansible -k -b -K -m command -a "ls -a /root"
  66. 47 ssh-copy-id ubuntu
  67. 48 ansible ubuntu -i inventory -u ansible -b -K -m command -a "ls -a /root"
  68. 49 ansible ubuntu -i inventory -u ansible -b -K -m copy -a "src=/tmp/sudoers dest=/etc/sudoers.d/ansible"
  69. 50 ansible ubuntu -i inventory -u ansible -m command -a "ls -a /root"
  70. 51 ansible ubuntu -i inventory -u ansible -b -m command -a "ls -a /root"
  71. 52 history
  72. 53 cd ansibleinthreeweeks/
  73. 54 ls
  74. 55 cd basics/
  75. 56 ls
  76. 57 cd ..
  77. 58 vim ansible.cfg
  78. 59 vim inventory
  79. 60 ansible all -m command -a "ls -a /root"
  80. 61 ansible-doc -l | wc
  81. 62 ansible-doc -l
  82. 63 ansible all -m ping
  83. 64 ansible all -m user -a "name=lisa"
  84. 65 ansible all -m command -a "useradd lisa"
  85. 66 ansible all -m command -a "id lisa"
  86. 67 ansible all -m user -a "name=lisa state=absent"
  87. 68 ansible all -m command -a "id lisa"
  88. 69 ansible-doc user
  89. 70 ansible rocky -m command -a "rpm -qa | grep python"
  90. 71 ansible rocky -m shell -a "rpm -qa | grep python"
  91. 72 ansible all -m copy -a 'content="hello world" dest=/tmp/testfile'
  92. 73 ansible all -a "cat /tmp/testfile"
  93. 74 ansible all -m package -a "name=nmap state=latest"
  94. 75 ansible all -m service -a "name=httpd state=started enabled=yes"
  95. 76 history
  96. 77 cat ansible.cfg
  97. 78 ls
  98. 79 cd basics/
  99. 80 ls
  100. 81 cp ../ansible.cfg .
  101. 82 cp ../inventory .
  102. 83 ls
  103. 84 vim install_and_start_httpt.yaml
  104. 85 ansible-playbook install_and_start_httpt.yaml
  105. 86 vim install_and_start_httpt.yaml
  106. 87 ../countdown 18
  107. 88 vim install_and_start_httpt.yaml
  108. 89 ansible-playbook install_and_start_httpt.yaml
  109. 90 ansible-playbook install_and_start_httpt.yaml -vvvv
  110. 91 ls
  111. 92 vim run_and_test_httpd.yaml
  112. 93 ansible-playbook run_and_test_httpd.yaml
  113. 94 ansible-doc -l | grep ufw
  114. 95 cat ansible.cfg
  115. 96 vim run_and_test_httpd.yaml
  116. 97 ansible-playbook run_and_test_httpd.yaml
  117. 98 vim variables_example.yaml
  118. 99 ansible-playbook variables_example.yaml
  119. 100 ansible-playbook variables_example.yaml -e user=anna
  120. 101 ansible ubuntu -m setup > ubuntu_facts.txt
  121. 102 less ubuntu_facts.txt
  122. 103 vim gather_facts.yaml
  123. 104 ansible-playbook gather_facts.yaml
  124. 105 vim old_facts.yaml
  125. 106 vim new_facts.yaml
  126. 107 ansible-playbook new_facts.yaml
  127. 108 vim new_facts.yaml
  128. 109 ansible-playbook new_facts.yaml
  129. 110 ls
  130. 111 cat new_facts.yaml
  131. 112 vim myvars.yaml
  132. 113 vim vars_file.yaml
  133. 114 ansible-playbook myvars.yaml
  134. 115 vim vars_file.yaml
  135. 116 vim myvars.yaml
  136. 117 ansible-playbook myvars.yaml
  137. 118 cat myvars.yaml
  138. 119 cat vars_file.yaml
  139. 120 mv myvars.yaml myvars
  140. 121 vimn vars_file.yaml
  141. 122 vim vars_file.yaml
  142. 123 ansible-playbook myvars.yaml
  143. 124 ansible-playbook vars_file.yaml
  144. 125 ip a
  145. 126 cat /etc/hosts
  146. 127 history
  147.  
Advertisement
Add Comment
Please, Sign In to add comment