added playbook to fetch remote hostnames, and a second that pushes ssh key from this server and the laptop

This commit is contained in:
dan
2024-03-07 04:48:24 +00:00
parent 2f092c789c
commit d4ada25944
4 changed files with 34 additions and 6 deletions

3
ansible.cfg Normal file
View File

@@ -0,0 +1,3 @@
[defaults]
privatekeyfile = /home/dan/.ssh/id_rsa.pub

13
hostname.yml Normal file
View File

@@ -0,0 +1,13 @@
---
- hosts: hosts
tasks:
- name: get hostnames
command: hostname
register: result
- name: return result
debug:
var: result.stdout

View File

@@ -1,9 +1,5 @@
[hosts]
192.168.86.238
192.168.86.83
192.168.86.213
192.168.86.216
192.168.86.202
192.168.86.40
192.168.86.213
192.168.86.234
192.168.86.223
192.168.86.226

16
keys.yml Normal file
View File

@@ -0,0 +1,16 @@
---
- hosts: hosts
tasks:
- name: push ssh key from this computer
ansible.posix.authorized_key:
user: dan
state: present
key: "{{ lookup('file', '/home/dan/.ssh/id_rsa.pub') }}"
- name: Push laptop key
ansible.posix.authorized_key:
user: dan
state: present
key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQJAVWcuwdF0vzqAWsZdzHxDrnsGUgrdwk54UYeb1sMe6nwbo7A3N+9knjS0QymFau2rzfUgh1ErsEM+qz2nbdtslkOlEFY1edkNRhGnVgCeKCqCdJ+MKuywK/4iazbZCezTchIZbX8Olft0Qig7TP9RlCWBzBffQgaJSxMjc0fe+dV+O2uTFjxD9KeRhlSf4DMon27b4D9eBb5aCnFMufPV1Tpu0xBygfENzxPV3I20ge41Kfms4UGradkaaz+uARwdi9eiAD+wutGDzf1ha+upqS6I0ji6VHziebAaPTuNXtykJFiXYTQnITswMotlT+vApf1REAfgS94E5zS7IBYGeDNks4xAArpO/I1G0Z5lbzim/t4q6ckOSjaGS1v6YTmiUulbkhS/u5wchMR/jzj2sRwKFgPOMyvBdNf1hYyUKgdRnzhyTuKRdwWW4WYQbeSvSt/Kgljt9l3ogP87dtrp7aEat+JOKgEbjACpV0XHxh/hwZ5m+6Ss8hkLmyYS9F9NGooA5V25Hl3MqDWLFuyxwg8Tj5dLreuiCbb/4yK087QUU+46xvU6yhxTdZdyh8xUXTRV94o9ZcKCfeyzoYuNu5U9wlz+GlDxiTENE21zotfzMzMEvwyUUGFnbjr1K7RZiYrgu6DGFI0hknh+68V3SkMXLSHCUv/mKfPXTfqpBw== rsa-key-20240305"