Error saying No handler was ready to authenticate 1 handlers were checked

0 votes

I'm trying to provision ec2 instance using ansible. 

cat /etc/ansible/hosts

   [local]
  localhost

cat /etc/ansible/ec2-vars/testserver.yml

   ec2_keypair: "ansible"
   ec2_security_group: "sg-*******"
   ec2_instance_type: "t2.micro"
   ec2_image: "ami-********"
   ec2_subnet_ids: ['subnet-*******','subnet-REDACTED','subnet-REDACTED']
   ec2_region: "us-east-1"
   ec2_tag_Name: "testserver"
   ec2_tag_Type: "testserver"
   ec2_tag_Environment: "development"
   ec2_volume_size: 8

cat /etc/ansible/provision-ec2.yml

     ---
      - hosts: localhost
        connection: local
        gather_facts: false
        user: root
        pre_tasks:
         - include_vars: ec2_vars/{{type}}.yml
        roles:
         - provision-ec2

cat /etc/ansible/roles/provision-ec2/tasks/main.yml

          ---
          - name: Provision EC2 Box
             local_action:
            module: ec2
           key_name: "{{ ec2_keypair }}"
           group_id: "{{ ec2_security_group }}"
            instance_type: "{{ ec2_instance_type }}"
            image: "{{ ec2_image }}"
            vpc_subnet_id: "{{ ec2_subnet_ids|random }}"
            region: "{{ ec2_region }}"
            instance_tags: '{"Name":"{{ec2_tag_Name}}","Type":"       {{ec2_tag_Type}}","Environment":"{{ec2_tag_Environment}}"}'
      assign_public_ip: yes
      wait: true
      count: 1
      volumes:
     - device_name: /dev/sda1
     device_type: gp2
      volume_size: "{{ ec2_volume_size }}"
      delete_on_termination: true
       register: ec2

       - debug: var=item
       with_items: ec2.instances

     - add_host: name={{ item.public_ip }} >
                     groups=tag_Type_{{ec2_tag_Type}},tag_Environment_{{ec2_tag_Environment}}
         ec2_region={{ec2_region}}
         ec2_tag_Name={{ec2_tag_Name}}
         ec2_tag_Type={{ec2_tag_Type}}
         ec2_tag_Environment={{ec2_tag_Environment}}
         ec2_ip_address={{item.public_ip}}
        with_items: ec2.instances

        - name: Wait for the instances to boot by checking the ssh port
       wait_for: host={{item.public_ip}} port=22 delay=60 timeout=320     state=started
   with_items: ec2.instances

Now I run the following command and this is what i get.

  [root@ip-**-**-*** ansible]# ansible-playbook -vv -i localhost, -e     "type=testservers" provision-ec2.yml
   Using /etc/ansible/ansible.cfg as config file

     PLAYBOOK: provision-ec2.yml   ****************************************************
 1 plays in provision-ec2.yml

  PLAY [localhost] ***************************************************************

 TASK [include_vars] ************************************************************
task path: /etc/ansible/provision-ec2.yml:7
 fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "file":    "/etc/ansible/ec2_vars/testservers.yml", "msg": "Source file not found."}

  NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @provision-ec2.retry

  PLAY RECAP *********************************************************************
  localhost                  : ok=0    changed=0    unreachable=0    failed=1
Mar 13, 2019 in Ansible by Neel
2,025 views

1 answer to this question.

0 votes

You are mixing underscore and hyphen.

cat /etc/ansible/ec2-vars/testserver.yml

include_vars: ec2_vars/{{type}}.yml

answered Mar 13, 2019 by Kim

Related Questions In Ansible

0 votes
1 answer
+1 vote
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,063 views
+2 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP