From 46fad1805882e9294a4f672ea13feef3aa976ba7 Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Tue, 3 Sep 2024 18:51:25 -0400 Subject: [PATCH] setup managed nodes v1 --- playbooks/setup_nodes.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 playbooks/setup_nodes.yml diff --git a/playbooks/setup_nodes.yml b/playbooks/setup_nodes.yml new file mode 100644 index 0000000..a78f72b --- /dev/null +++ b/playbooks/setup_nodes.yml @@ -0,0 +1,22 @@ +--- +- name: setup and manage nodes + hosts: servers + become: true + vars_files: + - ../vars/secrets.yml + 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') }}"