0

をスキップすることがNAT &ルート、パブリックおよびプライベートサブネットのペアでVPCを展開され、tasks/network/vpc.ymlを実行し、次のsite.yml、タスク

--- 
- name: Deployment Playbook 
    hosts: localhost 
    connection: local 
    gather_facts: no 
    environment: 
    AWS_DEFAULT_REGION: "{{ lookup('env', 'AWS_DEFAULT_REGION') | default('us-east-1', true) }}" 
    tasks: 
    - import_tasks: tasks/network/vpc.yml 

をご検討ください。下記に定義されているように:

--- 

# VPC 
- name: This deploys a VPC with a pair of public and private subnets spread across two Availability Zones. It deploys an Internet gateway, with a default route on the public subnets. It deploys a pair of NAT gateways (one in each zone), and default routes for them in the private subnets. 
    cloudformation: 
    stack_name: prod-vpc 
    state: present 
    region: us-east-1 
    disable_rollback: true 
    template: templates/infrastructure/network/vpc.yml 
    template_parameters: 
     EnvironmentName: "{{ environment_name }}" 
     VpcCIDR:   10.40.0.0/16 
     PublicSubnet1CIDR: 10.40.8.0/21 
     PublicSubnet2CIDR: 10.40.16.0/21 
     PrivateSubnet1CIDR: 10.40.24.0/21 
     PrivateSubnet2CIDR: 10.40.32.0/21 
    tags: 
     Environment: "{{ env }}" 
     Name: prod-vpc 
     Stack: "{{ stack_name }}" 
    when: vpc_stack is defined 
    register: prod_vpc_stack 

与えられたタスクは、雲の形成テンプレートを実行する必要がありますが、私はそれを実行したとき、それはしていません:

$ ansible --version 
    ansible 2.4.2.0 
     config file = None 
     configured module search path = [u'/Users/gaurish/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] 
     ansible python module location = /usr/local/Cellar/ansible/2.4.2.0_1/libexec/lib/python2.7/site-packages/ansible 
     executable location = /usr/local/bin/ansible 
     python version = 2.7.14 (default, Dec 10 2017, 14:22:32) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)] 

$ ansible-playbook site.yml 

PLAY [Deployment Playbook] ********************************************************************************************************************** 

TASK [This deploys a VPC with a pair of public and private subnets spread across two Availability Zones. It deploys an Internet gateway, with a default route on the public subnets. It deploys a pair of NAT gateways (one in each zone), and default routes for them in the private subnets.] *** 
skipping: [localhost] 

PLAY RECAP ************************************************************************************************************************************** 
localhost     : ok=0 changed=0 unreachable=0 failed=0 

私はansibleがタスクをスキップされ、何らかの理由で見ることができるように。なぜか分からない。誰か知っていますか?

答えて

1

これは簡単です - タスクはwhen: vpc_stack is definedを実行する必要がありますが、vpc_stackは質問に投稿したコードのどこにも定義されていないため、タスクはスキップされます。