add ip to inventory and add user ssh keys

This commit is contained in:
Mark O'Brien 2021-01-19 15:58:42 +00:00
parent 122ceec25b
commit 5304d523c2
5 changed files with 29 additions and 3 deletions

View file

@ -8,3 +8,20 @@
roles:
- ec2_instance
- name: Put ssh keys on host
hosts: "{{initiative_name}}"
remote_user: fedora
tasks:
- name: test
authorized_key:
user: fedora
state: present
key: "{{ lookup('file', 'secrets/{{item}}.pub') }}"
with_items:
- pingou
- mobrien
- wwoods

View file

@ -1,2 +1,2 @@
[datanommer]
100.26.18.234
datanommer ansible_host=100.26.18.234

View file

@ -41,6 +41,15 @@
vpc_subnet_id: "{{ subnet_id }}"
register: ec2_instance
- debug: msg="{{ec2_instance}}"
- debug: msg="{{ec2_instance.instances[0].public_ip_address}}"
- name: "Update inventory file"
ini_file:
dest: "inventory"
section: "{{ initiative_name }}"
option: "{{ initiative_name }} ansible_host"
value: "{{ec2_instance.instances[0].public_ip_address}}"
no_extra_spaces: yes
mode: 0666
state: present
backup: no

BIN
ansible/secrets/mobrien.pub Normal file

Binary file not shown.

BIN
ansible/secrets/wwoods.pub Normal file

Binary file not shown.