Advertisement
Guest User

Untitled

a guest
Apr 5th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.76 KB | None | 0 0
  1. ➜ ~ cat become.yml
  2. ---
  3. - hosts: localhost
  4. user: vagrant
  5. tasks:
  6. - shell: whoami
  7. register: result
  8.  
  9. - debug: var=result.stdout
  10.  
  11. - name: become_root_user
  12. become: true
  13. become_user: root
  14. shell: whoami
  15. register: sudo_test_result
  16.  
  17. - debug: var=sudo_test_result.stdout
  18.  
  19. - name: creating_new_app_user
  20. become: true
  21. become_user: root
  22. become_method: sudo
  23. user: name=app_user password=Bzs310di86b6E groups="adm,sudo" system=yes state=present
  24.  
  25. - name: become_app_user
  26. become: true
  27. become_user: app_user
  28. become_method: sudo
  29. shell: whoami
  30. register: app_user_test_result
  31.  
  32. - debug: var=app_user_test_result.stdout
  33.  
  34. ➜ ~ ansible-playbook -i realtime-automation/hosts-slaves become.yml -vvv --extra-vars='ansible_become_pass=4nsible'
  35.  
  36. Using /etc/ansible/ansible.cfg as config file
  37. [WARNING]: provided hosts list is empty, only localhost is available
  38.  
  39. 1 plays in become.yml
  40. ______
  41. < PLAY >
  42. ------
  43. \ ^__^
  44. \ (oo)\_______
  45. (__)\ )\/\
  46. ||----w |
  47. || ||
  48.  
  49. ______________
  50. < TASK [setup] >
  51. --------------
  52. \ ^__^
  53. \ (oo)\_______
  54. (__)\ )\/\
  55. ||----w |
  56. || ||
  57.  
  58. ESTABLISH LOCAL CONNECTION FOR USER: vagrant
  59. 127.0.0.1 EXEC ( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786340.21-197090646413082 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786340.21-197090646413082 )" )
  60. 127.0.0.1 PUT /tmp/tmpCbjAuD TO /home/vagrant/.ansible/tmp/ansible-tmp-1459786340.21-197090646413082/setup
  61. 127.0.0.1 EXEC LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1459786340.21-197090646413082/setup; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1459786340.21-197090646413082/" > /dev/null 2>&1
  62. ok: [localhost]
  63. ________________
  64. < TASK [command] >
  65. ----------------
  66. \ ^__^
  67. \ (oo)\_______
  68. (__)\ )\/\
  69. ||----w |
  70. || ||
  71.  
  72. task path: /home/vagrant/become.yml:5
  73. ESTABLISH LOCAL CONNECTION FOR USER: vagrant
  74. 127.0.0.1 EXEC ( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786340.72-63664888608764 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786340.72-63664888608764 )" )
  75. 127.0.0.1 PUT /tmp/tmpkhRn8W TO /home/vagrant/.ansible/tmp/ansible-tmp-1459786340.72-63664888608764/command
  76. 127.0.0.1 EXEC LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1459786340.72-63664888608764/command; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1459786340.72-63664888608764/" > /dev/null 2>&1
  77. changed: [localhost] => {"changed": true, "cmd": "whoami", "delta": "0:00:00.002035", "end": "2016-04-04 11:12:20.797767", "invocation": {"module_args": {"_raw_params": "whoami", "_uses_shell": true, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-04-04 11:12:20.795732", "stderr": "", "stdout": "vagrant", "stdout_lines": ["vagrant"], "warnings": []}
  78. ______________
  79. < TASK [debug] >
  80. --------------
  81. \ ^__^
  82. \ (oo)\_______
  83. (__)\ )\/\
  84. ||----w |
  85. || ||
  86.  
  87. task path: /home/vagrant/become.yml:8
  88. ok: [localhost] => {
  89. "result.stdout": "vagrant"
  90. }
  91. _________________________
  92. < TASK [become_root_user] >
  93. -------------------------
  94. \ ^__^
  95. \ (oo)\_______
  96. (__)\ )\/\
  97. ||----w |
  98. || ||
  99.  
  100. task path: /home/vagrant/become.yml:10
  101. ESTABLISH LOCAL CONNECTION FOR USER: vagrant
  102. 127.0.0.1 EXEC ( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786340.98-28464457805409 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786340.98-28464457805409 )" )
  103. 127.0.0.1 PUT /tmp/tmpS7xhoR TO /home/vagrant/.ansible/tmp/ansible-tmp-1459786340.98-28464457805409/command
  104. 127.0.0.1 EXEC /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=otcyhutloliufqcjvphapluoeaqgfmho] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-otcyhutloliufqcjvphapluoeaqgfmho; LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1459786340.98-28464457805409/command; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1459786340.98-28464457805409/" > /dev/null 2>&1'"'"''
  105. changed: [localhost] => {"changed": true, "cmd": "whoami", "delta": "0:00:00.002590", "end": "2016-04-04 11:12:21.083501", "invocation": {"module_args": {"_raw_params": "whoami", "_uses_shell": true, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-04-04 11:12:21.080911", "stderr": "", "stdout": "root", "stdout_lines": ["root"], "warnings": []}
  106. ______________
  107. < TASK [debug] >
  108. --------------
  109. \ ^__^
  110. \ (oo)\_______
  111. (__)\ )\/\
  112. ||----w |
  113. || ||
  114.  
  115. task path: /home/vagrant/become.yml:16
  116. ok: [localhost] => {
  117. "sudo_test_result.stdout": "root"
  118. }
  119. ______________________________
  120. < TASK [creating_new_app_user] >
  121. ------------------------------
  122. \ ^__^
  123. \ (oo)\_______
  124. (__)\ )\/\
  125. ||----w |
  126. || ||
  127.  
  128. task path: /home/vagrant/become.yml:18
  129. ESTABLISH LOCAL CONNECTION FOR USER: vagrant
  130. 127.0.0.1 EXEC ( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786341.26-134368257733119 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1459786341.26-134368257733119 )" )
  131. 127.0.0.1 PUT /tmp/tmpp8ohfm TO /home/vagrant/.ansible/tmp/ansible-tmp-1459786341.26-134368257733119/user
  132. 127.0.0.1 EXEC /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=hyakgsdksttrdqbbstjpciyjhgkhwydl] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-hyakgsdksttrdqbbstjpciyjhgkhwydl; LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1459786341.26-134368257733119/user; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1459786341.26-134368257733119/" > /dev/null 2>&1'"'"''
  133. ok: [localhost] => {"append": false, "changed": false, "comment": "", "group": 996, "groups": "adm,sudo", "home": "/home/app_user", "invocation": {"module_args": {"append": false, "comment": null, "createhome": true, "expires": null, "force": false, "generate_ssh_key": null, "group": null, "groups": "adm,sudo", "home": null, "login_class": null, "move_home": false, "name": "app_user", "non_unique": false, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "remove": false, "shell": null, "skeleton": null, "ssh_key_bits": "2048", "ssh_key_comment": "ansible-generated on vagrant", "ssh_key_file": null, "ssh_key_passphrase": null, "ssh_key_type": "rsa", "state": "present", "system": true, "uid": null, "update_password": "always"}, "module_name": "user"}, "move_home": false, "name": "app_user", "password": "NOT_LOGGING_PASSWORD", "shell": "", "state": "present", "uid": 997}
  134. ________________________
  135. < TASK [become_app_user] >
  136. ------------------------
  137. \ ^__^
  138. \ (oo)\_______
  139. (__)\ )\/\
  140. ||----w |
  141. || ||
  142.  
  143. task path: /home/vagrant/become.yml:24
  144. ESTABLISH LOCAL CONNECTION FOR USER: vagrant
  145. 127.0.0.1 EXEC ( umask 22 && mkdir -p "$( echo /tmp/ansible-tmp-1459786341.44-100095688149056 )" && echo "$( echo /tmp/ansible-tmp-1459786341.44-100095688149056 )" )
  146. 127.0.0.1 PUT /tmp/tmpip4yk9 TO /tmp/ansible-tmp-1459786341.44-100095688149056/command
  147. 127.0.0.1 EXEC chmod a+r /tmp/ansible-tmp-1459786341.44-100095688149056/command
  148. 127.0.0.1 EXEC /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=pupzhzchihxbrtwmuubhapnpfpukyjyo] password: " -u app_user /bin/sh -c '"'"'echo BECOME-SUCCESS-pupzhzchihxbrtwmuubhapnpfpukyjyo; LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /tmp/ansible-tmp-1459786341.44-100095688149056/command'"'"''
  149. 127.0.0.1 EXEC rm -f -r /tmp/ansible-tmp-1459786341.44-100095688149056/ > /dev/null 2>&1
  150. changed: [localhost] => {"changed": true, "cmd": "whoami", "delta": "0:00:00.003000", "end": "2016-04-04 11:12:21.539930", "invocation": {"module_args": {"_raw_params": "whoami", "_uses_shell": true, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-04-04 11:12:21.536930", "stderr": "", "stdout": "app_user", "stdout_lines": ["app_user"], "warnings": []}
  151. ______________
  152. < TASK [debug] >
  153. --------------
  154. \ ^__^
  155. \ (oo)\_______
  156. (__)\ )\/\
  157. ||----w |
  158. || ||
  159.  
  160. task path: /home/vagrant/become.yml:31
  161. ok: [localhost] => {
  162. "app_user_test_result.stdout": "app_user"
  163. }
  164. ____________
  165. < PLAY RECAP >
  166. ------------
  167. \ ^__^
  168. \ (oo)\_______
  169. (__)\ )\/\
  170. ||----w |
  171. || ||
  172.  
  173. localhost : ok=8 changed=3 unreachable=0 failed=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement