小编Dhi*_*esh的帖子

Azure 中的 Ansible VM 配置没有名为 Packaging.version 的模块

我正在使用 CentOS 7.2 并尝试通过 Ansible 使用模块“azure_rm_virtualmachine”在 azure 中配置 VM,并收到错误消息“No module named Packaging.version” 下面是我的错误

回溯(最近一次调用):文件“/tmp/ansible_7aeFMQ/ansible_module_azure_rm_virtualmachine.py”,第 445 行,来自 ansible.module_utils.azure_rm_common 导入 * 文件“/tmp/ansible_7aeFMQ/ansible_modlib.zip/ansible/module_pyrms_utils ",第 29 行,在 ImportError 中:没有名为 Packaging.version 的模块

致命:[本地主机]:失败!=> { "changed": false, "failed": true, "module_stderr": "Traceback (last last call last):\n File \"/tmp/ansible_7aeFMQ/ansible_module_azure_rm_virtualmachine.py\", line 445, in \n from ansible.module_utils.azure_rm_common import *\n File \"/tmp/ansible_7aeFMQ/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py\", line 29, in \nImportError: No module named packaging.version\n", " module_stdout": "", "msg": "MODULE FAILURE", "rc": 0 }

下面是我的剧本,我使用的是 ansible 版本 2.3.0.0 和 python 版本 2.7.5 和 pip 9.0.1

  • 名称:在 …

azure python-2.7 ansible

4
推荐指数
2
解决办法
3270
查看次数

ansible set_fact if-else 失败

我正在尝试使用 if-else 根据条件设置 set_fact 值,以下是我用于 if-else 条件的语法。

- name: set the server details
  set_fact:
    ad_server: "{{ '{{ server.westeurope }}' if ('{{ ansible_local.vdc.location }}' == 'westeurope') else '{{ server.eastus2 }}' }}"
    ad_server_ip: "{% if'{{ ansible_local.vdc.location }}'=='westeurope' %}{{ server_ip.westeurope }}{% else %}{{ server_ip.eastus2 }}{% endif %}"

- debug:
    msg: "{{ ansible_local.vdc.location }},{{ ansible_local.vdc.binaryrepo_url }},{{ ad_server }},{{ ad_server_ip }}"
Run Code Online (Sandbox Code Playgroud)

我已经用下面提到的细节声明了我的变量部分:

server:
  westeurope: WIN030123
  eastus2: WIN100270
server_ip:
  westeurope: 10.x.x.x
  eastus2: 10.x.x.x
Run Code Online (Sandbox Code Playgroud)

我的 if-else 条件无法获取 if 语句的值,并且始终获取 else 条件的值..有人可以为我提供这种情况的正确语法吗?

if-statement ansible

1
推荐指数
1
解决办法
3545
查看次数

标签 统计

ansible ×2

azure ×1

if-statement ×1

python-2.7 ×1