I have created local configuration and Amazon Auto-scaling group.
By using this code.

    --- 
    - 
      local_action: 
        image_id: ami-61f9324
        instance_type: t2.micro
        module: ec2_lc
        name: nice-lc
        region: us-west-2
        security_groups: launch-wizard-1
      name: "Create lc"
    - 
      local_action: 
        desired_capacity: 2
        health_check_period: 5
        health_check_type: ELB
        launch_config_name: nice-lc
        load_balancers: nice-lb1
        max_size: 10
        min_size: 2
        module: ec2_asg
        name: nice-asg
        region: us-west-2
      name: "Create asg"

I'm using `ec2.py` and `ec2.ini` files for inventory.

So now Local configuration and Auto-scaling group created and according 
desired capacity I have defined, 2 instance are launched.

Now I want to run tasks on those 2 instance. 

For that I'm using this yaml file.

    ---
    
    - name: Example of provisioning servers
      hosts: 127.0.0.1
      connection: local
      tasks:
        - name: Add EP2 instances to host group
          local_action: add_host hostname={{ ec2_publicIp }} 
groupname=launch-wizard-1
          with_items: ec2.instances
    
        - name: Add tag to instances
          local_action: ec2_tag resource={{ item.id }} region=us-west-2 
state=present
          with_items: ec2.instances
          args:
            tags:
              Name: nice-ec2
    
        - name: Wait for SSH to be available
          pause: minutes=1
    
    - name: Configure provisioned servers
      hosts: tag_aws_autoscaling_groupName_nice_asg
      user: ubuntu
      sudo: True
      gather_facts: True
      tasks:
        - name: restart nginx
          service: name=nginx state=restarted


When I run this file, I'm get error: 

One or more undefined variables: 'ec2_publicIp' is undefined


Questions:


1. I want to run tasks like restarting nginx and add tag on instance 
launched by amazon auto-scaling group.


2. Am I doing right? Looks I do not even need to `add host` if I just want 
to run some task on instance launched by asg. 

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2e0a1937-5d63-442b-8e75-e8ce8f371061%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to