2024-09-03 22:51:25 +00:00
|
|
|
---
|
|
|
|
- name: setup and manage nodes
|
|
|
|
hosts: servers
|
|
|
|
become: true
|
|
|
|
vars_files:
|
|
|
|
- ../vars/secrets.yml
|
2024-09-04 00:54:44 +00:00
|
|
|
- ../vars/packages.yml
|
2024-09-03 22:51:25 +00:00
|
|
|
tasks:
|
|
|
|
- name: create user ansible on managed nodes
|
|
|
|
user:
|
|
|
|
name: ansible
|
|
|
|
- name: set password for ansible user
|
|
|
|
shell:
|
|
|
|
cmd: echo ansible:{{ become_password }} | chpasswd
|
|
|
|
- name: setup user ansible with elevated priviledges
|
|
|
|
copy:
|
|
|
|
content: "ansible ALL=(ALL) PASSWD: ALL"
|
|
|
|
dest: /etc/sudoers.d/ansible
|
|
|
|
- name: copy ssh keys from control to managed nodes
|
|
|
|
ansible.posix.authorized_key:
|
|
|
|
user: ansible
|
|
|
|
state: present
|
|
|
|
key: "{{ lookup('file', '/home/mango/.ssh/id_rsa.pub') }}"
|
2024-09-04 00:54:44 +00:00
|
|
|
|
|
|
|
- name: Core packages
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
loop: "{{ minimal_debian_packages }}"
|
|
|
|
|