Skip to content

Instantly share code, notes, and snippets.

@bryanwb
Created July 9, 2015 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanwb/b084d49538c8f42ccc5c to your computer and use it in GitHub Desktop.
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
Copy link

halberom commented Jul 9, 2015

you could try

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

@bryanwb
Copy link
Author

bryanwb commented Jul 9, 2015

wonderful, tks @halberom

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