Private Key path for ec2_lc module under userdata field

19 views
Skip to first unread message

Bhotu

unread,
May 11, 2016, 3:35:08 PM5/11/16
to Ansible Project
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"





Reply all
Reply to author
Forward
0 new messages