无法从Ansible中的ec2_scaling_policy模块检索AWS扩展策略信息

时间:2014-07-10 21:13:44

标签: amazon-web-services ansible autoscaling ansible-playbook

我正在尝试创建AWS扩展策略并为其附加指标警报。根据我的理解,ec2_metric_alarm模块需要扩展策略的ARN,以便它可以与自己关联。

但是,在从ec2_scaling_policy模块的输出创建新的扩展策略后,我似乎无法获得ARN。目前我正在尝试注册ec2_scaling策略模块的结果。例如,我的剧本看起来像这样:

- name: Create scaling policy and associate it with autoscaling group
  ec2_scaling_policy:
    state: present
    region: us-east-1
    name: "test-scaleup-policy"
    adjustment_type: "ChangeInCapacity"
    asg_name: "test-asg"
    scaling_adjustment: 1
    min_adjustment_step: 1
    cooldown: 300
  register: sp_result

- name: Debug result of scaling policy creation
  debug: var=sp_result

- name: Create metric alarm and associate it with autoscaling policy
  action:
    module: ec2_metric_alarm
    state: present
    alarm_actions: ["{{ sp_result.arn }}"]
    etc...

调试模块打印出:

TASK: [Debug] ***************************************************************** 
ok: [localhost] => {
   "sg_result": {
      "changed": false, 
      "invocation": {
      "module_args": "", 
      "module_name": "ec2_scaling_policy"
}}}

根据this merged pull request,ARN应包含在模块返回的数据中。我仍然是Ansible的新手,所以我想知道我是否试图以错误的方式捕获这些信息,例如当我应该使用其他东西时使用注册?否则,我还应该做些什么吗?

1 个答案:

答案 0 :(得分:0)

该更改已合并到Ansible的devel分支中,但尚未发布。

相关问题