From 7ff34396c7afee79ccc6e26c0e10eaaecc880f65 Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Thu, 3 Oct 2024 17:41:45 -0400 Subject: [PATCH] updated inventory and started setup_key playbook --- inventory/inventory | 2 ++ playbooks/setup_keys.yml | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 playbooks/setup_keys.yml diff --git a/inventory/inventory b/inventory/inventory index 55d40e1..4d30d29 100644 --- a/inventory/inventory +++ b/inventory/inventory @@ -7,6 +7,8 @@ doc ansible_user=pollen [local] proxmox ansible_user=root pihole ansible_user=pollen +bastion ansible_user=mango +debianV ansible_user=ansible [windows] bane ansible_user=ansible ansible_connection=winrm ansible_winrm_transport=basic ansible_port=5985 ansible_winrm_server_cert_validation=ignore diff --git a/playbooks/setup_keys.yml b/playbooks/setup_keys.yml new file mode 100644 index 0000000..ac1f317 --- /dev/null +++ b/playbooks/setup_keys.yml @@ -0,0 +1,18 @@ +--- +- name: Sets up access to managed nodes on the control node + hosts: all + become: yes + gather_facts: true + tasks: + - name: create ansible user on managed nodes + ansible.builtin.user: + name: ansible + shell: /bin/bash + groups: sudo + append: yes + + - name: set authorized key for ansible user + ansible.posix.authorized_key: + user: ansible + state: present + key: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/id_rsa.pub') }}"