Advertisement
k3NGuru

Untitled

Jan 24th, 2022 (edited)
1,187
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # ansible-playbook main.yaml -i hosts.ini -k -b -v
  2. ---
  3. - hosts: all
  4.   tasks:
  5.   - name: Убеждаемся, что есть группа 'wheel'
  6.     group:
  7.       name: wheel
  8.       state: present
  9.  
  10.   - name: Добавляем пользователя ansible в группу wheel
  11.     user:
  12.       name: ansible
  13.       comment: Ansible Management User
  14.       shell: /bin/bash
  15.       group: wheel
  16.       append: yes
  17.  
  18.   - name: Отключаем запрос sudo пароля у группы wheel
  19.     lineinfile:
  20.       path: /etc/sudoers.d/ansible
  21.       line: 'ansible ALL=(ALL) NOPASSWD: ALL'
  22.       state: present
  23.       mode: 0440
  24.       create: yes
  25.       validate: 'visudo -cf %s'
  26.  
  27.   - name: Создаем SSH папку и назначаем права доступа
  28.     file: path=/home/ansible/.ssh state=directory owner=ansible group=ansible mode=700
  29.    
  30.   - name: Копируем SSH ключ
  31.     authorized_key: user=ansible key={{ lookup('file', 'ansible.pub') }} state=present
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement