From 5304d523c2a6255585523af2bc12a5db65fd72a9 Mon Sep 17 00:00:00 2001 From: Mark O'Brien Date: Tue, 19 Jan 2021 15:58:42 +0000 Subject: [PATCH] add ip to inventory and add user ssh keys --- ansible/create_ec2.yml | 17 +++++++++++++++++ ansible/inventory | 2 +- ansible/roles/ec2_instance/tasks/main.yml | 13 +++++++++++-- ansible/secrets/mobrien.pub | Bin 0 -> 767 bytes ansible/secrets/wwoods.pub | Bin 0 -> 779 bytes 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 ansible/secrets/mobrien.pub create mode 100644 ansible/secrets/wwoods.pub diff --git a/ansible/create_ec2.yml b/ansible/create_ec2.yml index 2b29075..2664835 100644 --- a/ansible/create_ec2.yml +++ b/ansible/create_ec2.yml @@ -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 + diff --git a/ansible/inventory b/ansible/inventory index 553d009..b36272f 100644 --- a/ansible/inventory +++ b/ansible/inventory @@ -1,2 +1,2 @@ [datanommer] -100.26.18.234 +datanommer ansible_host=100.26.18.234 diff --git a/ansible/roles/ec2_instance/tasks/main.yml b/ansible/roles/ec2_instance/tasks/main.yml index b20758e..0f37913 100644 --- a/ansible/roles/ec2_instance/tasks/main.yml +++ b/ansible/roles/ec2_instance/tasks/main.yml @@ -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 diff --git a/ansible/secrets/mobrien.pub b/ansible/secrets/mobrien.pub new file mode 100644 index 0000000000000000000000000000000000000000..3dbdb8bdf5019fdd5bf340d34b5508cde57be019 GIT binary patch literal 767 zcmV~)m1`!;#^sSx;vCRr7q#MhP;cP<}gIj>Uv{GQ9pgl zA7>J9Eq@&b)^YzN{JjVW-p22JlQ#V)YvnBsA&%HBr!nwQ|*-WQZ7reYGE+ z5x34X^uS4lMD8@3z8h{}fZz%E=#ZPr<#i7XSF&#wOIvBl8lZ_Rre^R}B>B`Um`=ra zK$pqW2d5mOnZR!kb=8LqS3S6xT}tOu`3v$b=9TYqdauf>hR8SH$hqeeV~Y-+y-)m2 z+B47`*8Tf`<|BWzh@JupEGD7_2J7x1VF(Jn6J{gAqKheIiO1s9LeCAERYDk$nBkg9 zeO!fZgIpFU6CR)KhX6$rV|_?M@he}_H=q&C0~UzREuvQ-xTc<1hma~N{&v*bjZO07 zuSU{8E9SMty2bj|gKx4Dgo()Xpja3-APZ;c2EL9UNGw?%_)wPHcF0qid-TXf9xSCS zfmb=T(|$2KSf7cZIyJr^&xCjpb8kyh)D!-kgK}ZoA-dyR;2p;*t0jS*?!us7R=mR# za)34=0V|yxwU8R=^}NNgooGX`fL~tR9>`<{jcLNlme5D1X2UoM54L4S8g_K_J=`cf zKIV5#Vc%vD<1J?gWu?d1Yt!ed%!hW`c7j}q}Ho9xpA=CAf|^dq-F7Jh9fJ@%s3-rxQ4Z0rqK(yTbOHlEsIJ3U2fhNc%A?N literal 0 HcmV?d00001 diff --git a/ansible/secrets/wwoods.pub b/ansible/secrets/wwoods.pub new file mode 100644 index 0000000000000000000000000000000000000000..90d4262d9fcbc153045d36761e05751ba5fa7fb7 GIT binary patch literal 779 zcmV+m1N8g=M@dveQdv+`02w$rB}e`|$7X0SYyag{e{MNczaG-EY({LKk6Dy z0RT4+z#lb2I&v&p$U0c*L{{LW+c^l+71ADRcG6K)WrV>PM%Y62nqdq#BX|9(1xlR9<$3LK&~|OqQk4Zic}R40FwC@g!;nJYN2V^c>RTo$Oi+*n(J)kabUw)1zzF{m*NiQPOKtrPR zkGprw)Ge0K+Es(eXz|B2M9#HGgWgE>b)wzvzdss%1*r}7Jb*oCw8Rc+ zm&3-xLJk;)*RVAq;gKqTpI+)-)vRNsyWCfwOmUrdHSRgMEEi)Qwa~!h@)EXYX2Dv3Qg!z7rTeBrN$s+U4G3?otm~%^eqbl4qj8I5axY z_?S=#E1rZ4H;uG8mu@jk5_55^zdA>^#@>}#Yu)8pT+`2E$=YoW zQj~Vct0x8v^9S!R=U5|LsFRG^5;73;Vt?TIUI?(E7g$sCP{i00cdnlRE++$I^c;x* z(dP>v%_-HJsip2q_-vjUjAt8Xn+Jt2!|$J@!q2SducG-b_D