I am trying to create new instance with ec2_lc module in ansible. At the 
time of bootstraping, I want to install some configurations. Those 
configurations come from the public github file, its basically the ansible 
playbook. But I need to mention the path for the private key file under 
"hosts". Currently private key comes from S3 bucket. Although we cannot put 
private key publicly on to the s3 bucket. Its mandatory to have private key 
to run ansible playbook under userdata field at the time of instance 
creation in my case. 

What could be the possible way to define private key which only I can see ?


---

#- name: Create Launch Configuration

#  hosts: localhost

#  gather_facts: no

#  tasks:

    - name: Launch the configurations for the ASG

      local_action:

        module: ec2_lc

        state: present

        assign_public_ip: yes

        name: elasticsearchlaunchconfiguration16

        instance_type: m3.medium

        key_name: tempkey1

        instance_monitoring: yes

        region: us-east-1

        image_id: ami-fce3c696

        security_groups: ['sg-1234abcd']

        user_data: "#!/bin/bash\n

                   # Update repositories\n

                   sudo apt-get update\n

                   sudo apt-get install -y python-setuptools\n

                   sudo apt-get install -y python-pip\n

                   sudo apt-get install -y python-dev\n

                   sudo pip install markupsafe\n

                   sudo pip install jinja2\n

                   sudo pip install boto\n

                   sleep 1\n

                   sudo apt-get install -y git\n

                   sudo pip install ansible==1.8.4\n

                   sudo apt-get -y update\n

                   cd /home\n

                   git clone https://github.com/abcdedfg/ansibleconfig.git\n

                   cd ansibleconfig\n

                   sudo wget https://s3.amazonaws.com/automation/cred-aws\n

                   sudo wget https://s3.amazonaws.com/automation/key1.pem\n

                   . ./cred-aws\n

                   sudo chmod 400 key1.pem\n

                   export ANSIBLE_HOST_KEY_CHECKING=False\n

                   ansible-playbook -i hosts main.yml\n

                   sudo apt-get -y update"





-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5cf7bd01-8d88-4061-b424-728854fe5bf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to