通过几个文件去后,我得出的结论是,我不能使用with_items的roles.
所以,我创建了一个filter_plugin生成角色列表的列表.
这是我的Play:
---
- name: Boostrap vpc and subnets with route table
  hosts: localhost
  connection: local
  gather_facts: no
  pre_tasks:
    - include_vars: ec2_vars/common/regions.yml
    - include_vars: environment.yml
  roles:
    - {
        role: vpc,
        ec2_region: 'ap-southeast-2'
      }
    - {
        role: vpc,
        ec2_region: "ap-southeast-1",
      }
    - {
        role: vpc,
        ec2_region: "us-west-2",
      }
我想动态生成上述角色,为此我创建了一个filter_plugin生成字典列表并且正常工作的角色.
这是我的插件:
# this is for generating vpc roles
def roles(ec2_regions):
    return [{'role': 'vpc', 'ec2_region': ec2_region} for ec2_region in ec2_regions]
class FilterModule(object): …curl 当我使用without 打开网址时-k,我的请求正在通过,并且我能够看到预期的结果。
$ curl -vvv https://MYHOSTNAME/wex/archive.info -A SUKU$RANDOM
*   Trying 10.38.202.192...
* Connected to MYHOSTNAME (10.38.202.192) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.MYCNAME
* Server certificate: ProdIssuedCA1
* Server certificate: InternalRootCA
> GET /wex/archive.info HTTP/1.1
> Host: MYHOSTNAME
> User-Agent: SUKU19816
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: nginx/1.10.2
< Date: Thu, 26 Jan 2017 01:08:40 GMT
< Content-Type: text/html;charset=ISO-8859-1
< Content-Length: 19
< Connection: keep-alive
< Set-Cookie: …我想SIGNAL在.5几秒钟之后发送一个进程.
也许这不是一个好主意,但我想为一个不寻常的临时案例做这件事.
我试过跟随,但它不起作用.
(sleep .5;kill -9)| some_process