Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. ```
  2. - hosts: "{{ hosts }}"
  3. become: true
  4. become_method: su
  5. become_user: root
  6. gather_facts: no
  7. pre_tasks:
  8. - name: Install Python
  9. raw: sudo apt-get -y install python
  10.  
  11. tasks:
  12. - name: Add 'admin' User
  13. user:
  14. name: admin
  15. shell: /bin/bash
  16.  
  17. - name: Allow 'admin' user to have passwordless sudo
  18. lineinfile:
  19. dest: /etc/sudoers
  20. state: present
  21. regexp: '^%admin'
  22. line: 'admin ALL=(ALL) NOPASSWD: ALL'
  23.  
  24. - name: Set authorized key took from file
  25. authorized_key:
  26. user: admin
  27. state: present
  28. key: "{{ lookup('file', '/home/admin/.ssh/id_rsa.pub') }}"
  29. ```
  30. > sudo ansible-playbook default.yml -e "hosts=YOUR_HOSTS ansible_user=root ansible_ssh_pass=YOUR_PASSWORD" --ask-become-pass
  31.  
  32. - ansible_user, ansible_ssh_pass: ssh 인증이 아닌 password 인증을 하기 위한 명령어
  33. - ask-become-pass: tasks 에 sudo 권한이 필요한 명령어가 있는 경우 become_user 의 비밀번호 전달
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement