amazon web services - creating instance and installing git using ansible -


i created ec2 instance using ansible after creating instance not downloading git package. code:

ec2:        key_name: "{{ key }}"        aws_access_key: "{{ aws_id }}"        aws_secret_key: "{{ aws_key }}"        region: "{{ aws_region }}"        image: ami-2322b6123        instance_type: t2.micro     - name: install  git      yum: name=git state=present 

so , can please know if there way install package after creating ec2 instance using ansible?

after launching ec2 instance, have run play (to install git) in newly launched instance, not in control host. have register launched, add host inventory , install package. follow example in ansible documentation: ec2 module

- name: create instance   ...   ...   tasks:     - name: launch instance       ec2:        key_name: "{{ key }}"        aws_access_key: "{{ aws_id }}"        aws_secret_key: "{{ aws_key }}"        region: "{{ aws_region }}"        image: ami-2322b6123        instance_type: t2.micro       register: ec2      - name: add new instance host group       add_host: hostname={{ item.public_ip }} groupname=launched       with_items: '{{ec2.instances}}'      - name: wait ssh come       wait_for: host={{ item.public_dns_name }} port=22 delay=60 timeout=320 state=started       with_items: '{{ec2.instances}}'  - name: configure instance(s)   hosts: launched   gather_facts: true   ...   tasks:    - name: install  git      yum: name=git state=present 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -