Skip to content

Instantly share code, notes, and snippets.

@bryanwb
Created July 9, 2015 10:05
Show Gist options
  • Select an option

  • Save bryanwb/b084d49538c8f42ccc5c to your computer and use it in GitHub Desktop.

Select an option

Save bryanwb/b084d49538c8f42ccc5c to your computer and use it in GitHub Desktop.
how to DRY this up?
- command: "aws ec2 describe-subnets --filters Name=tag:Tier,Values=pub Name=vpc-id,Values={{aws_vpc_id}}"
register: awscli
- set_fact:
pub_subnets: "{{awscli.stdout | from_json}}"
- set_fact:
pub_subnet: "{{pub_subnets['Subnets']|first}}"
- set_fact:
pub_subnet_id: "{{pub_subnet['SubnetId']}}"
@halberom

halberom commented Jul 9, 2015

Copy link
Copy Markdown

you could try

- set_fact:
    pub_subnet_id: "{{ (awscli.stdout | from_json)['Subnets'][0]['SubnetId'] }}"

@bryanwb

bryanwb commented Jul 9, 2015

Copy link
Copy Markdown
Author

wonderful, tks @halberom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment