Not sure if I'm doing this wrong or not, so I figured I'd ask.--I have a playbook to apply a role, but the role has a conditional. If the conditional evaluates to false, the role should be skipped.# service.yml
---- name: Create EC2 Instancesgather_facts: Falsehosts: localvars_files:- vars/defaults.yml- vars/{{deploy_env}}.yml- vars/{{region}}.yml- vars/{{service}}.ymlroles:- ec2-box- { role: ec2-elb, when: elb }In this case elb is set to false, so all the tasks in the ec2-elb role should be skipped.However, I also run the playbook using tags.ansible-playbook -vvvv -i hosts service.yml --tags configure,start -e service=myservice
And all of the tasks in ec2-elb have tags assigned:# roles/ec2-elb/tasks/main.yml
---
- name: Create ELBlocal_action:module: ec2_elb_lbname: "{{deploy_env}}-{{service}}"state: presentcross_az_load_balancing: yessecurity_group_ids: "{{sg_ids}}"region: "{{region}}"subnets:- {{public_vpc_subnet_a}}- {{public_vpc_subnet_a}}- {{public_vpc_subnet_a}}listeners:- protocol: httpsload_balancer_port: 443instance_protocol: httpinstance_port: "{{service_port}}"ssl_certificate_id: "{{ssl_cert_arn}}"health_check:ping_protocol: httpping_port: 6990ping_path: "/1.0/status"response_timeout: 5interval: 10unhealthy_threshold: 2healthy_threshold: 2register: elbtags:- configure- start- stop- restart- name: Wait Until ELB Respondslocal_action:module: wait_forhost: "{{elb.elb.dns_name}}"port: 443timeout: 300tags:- start- configure- restartGiven this approach, I would expect that if elb evalutates to False or undefined, the ec2-elb role would be skipped.Unfortunately, It seems the tasks within the ec2-elb role still attempt to execute based off the tags:TASK: [ec2-elb | Create ELB] **************************************************skipping: [localhost -> 127.0.0.1]TASK: [ec2-elb | Wait Until ELB Responds] *************************************fatal: [localhost -> 127.0.0.1] => error while evaluating conditional: {u'skipped': True, u'changed': False}FATAL: all hosts have already failed -- abortingPLAY RECAP ********************************************************************to retry, use: --limit @/home/mmorgan/service.retrylocalhost : ok=5 changed=1 unreachable=1 failed=0
Am I doing something wrong here, or is this a bug?Thanks!
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9817e427-0d4d-4732-9e1f-0022396d41a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.