maabara/playbooks/control_node.yml

38 lines
928 B
YAML
Raw Normal View History

2024-09-01 20:26:50 +00:00
---
- name: sets up the control node
hosts: localhost
vars_files:
- ../vars/secrets.yml
tasks:
- name: create the ansible control user
user:
name: ansible
generate_ssh_key: true
2024-09-03 22:50:45 +00:00
2024-09-01 20:26:50 +00:00
- name: Create the password for the control user
shell:
cmd: echo {{ become_password }} | passwd --stdin ansible
when: ansible_os_family == 'RedHat'
#when: ansible_facts['ansible_os_family'] == 'RedHat'
2024-09-03 22:50:45 +00:00
2024-09-01 20:26:50 +00:00
- name: install chpasswd on debian family os
shell:
cmd: echo ansible:{{ become_password }} | chpasswd
when: ansible_os_family == 'Debian'
2024-09-03 22:50:45 +00:00
- name: give the user elevated priviledges
copy:
content: "ansible ALL=(ALL) NOPASSWD: ALL"
dest: /etc/sudoers.d/ansible
- name: add the user to the specified groups
user:
name: ansible
append: true
groups:
- kvm
- libvirt