os_user(和其他os模块)无法建立连接错误

时间:2017-10-13 18:38:24

标签: ansible openstack keystone

同样的ansible playbook /角色在我的openstack自由部署中运行良好,但是我的新派克openstack(使用OAD部署)我运行任何os模块都有问题。以下示例:

ansible version:2.3.2.0

openstack实用程序容器上的cloud.yml:

# Ansible managed
clouds:
  default:
    auth:
      auth_url: http://172.29.236.10:5000/v3
      project_name: admin
      tenant_name: admin
      username: admin
      password: admin
      user_domain_name: Default
      project_domain_name: Default
    region_name: RegionOne
    interface: internal
    identity_api_version: "3"

作用/任务:

---

- name: Install random password generator package
  apt: name={{item}} state=present
  with_items:
   - apg

- name: Random generate passwords
  command: apg -n {{ pass_cnt }} -M NCL -q
  register: passwdss

- name: Create users
  os_user:
    cloud: "{{CLOUD_NAME}}"
    state: present
    name: "{{ item.0 }}"
    password: "{{ item.1 }}"
    domain: default
  with_together:
    - "{{userid}}"
    - "{{passwdss.stdout_lines}}"

- name: Create user environments
  os_project:
    cloud: "{{CLOUD_NAME}}"
    state: present
    name: "{{ item }}"
    description: "{{ item }}"
    domain_id: default
    enabled: True
  with_items: "{{tenantid}}"

- name: Assign user to specified role in designated environment
  os_user_role:
    cloud: "{{CLOUD_NAME}}"
    user: "{{ item.0 }}"
    role: "{{ urole }}"
    project: "{{ item.1 }}"
  with_together: 
    - "{{userid}}"
    - "{{tenantid}}"

- name: User password assignment
  debug: msg="User {{ item.0 }} was added to {{ item.2 }} project, with the assigned password of {{ item.1 }}"
  with_together:
    - userid
    - passwdss.stdout_lines
    - tenantid

初始passwd生成器和密码创建任务完成没有问题。但是一旦运行os_user,我就会收到以下错误:

ndebug2: Received exit status from master 0\r\nShared connection to 172.29.239.130 closed.\r\n", 
    "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_BXmCwn/ansible_module_os_user.py\", line 284, in <module>\r\n    main()\r\n  File \"/tmp/ansible_BXmCwn/ansible_module_os_user.py\", line 220, in main\r\n    user = cloud.get_user(name)\r\n  File \"/usr/local/lib/python2.7/dist-packages/shade/openstackcloud.py\", line 1016, in get_user\r\n    return _utils._get_entity(self.search_users, name_or_id, filters)\r\n  File \"/usr/local/lib/python2.7/dist-packages/shade/_utils.py\", line 220, in _get_entity\r\n    entities = func(name_or_id, filters, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/shade/openstackcloud.py\", line 999, in search_users\r\n    users = self.list_users()\r\n  File \"/usr/local/lib/python2.7/dist-packages/shade/openstackcloud.py\", line 981, in list_users\r\n    data = self._identity_client.get('/users')\r\n  File \"/usr/local/lib/python2.7/dist-packages/shade/openstackcloud.py\", line 419, in _identity_client\r\n    'identity', version_required=True, versions=['3', '2'])\r\n  File \"/usr/local/lib/python2.7/dist-packages/shade/openstackcloud.py\", line 496, in _discover_endpoint\r\n    self.keystone_session, base_url)\r\n  File \"/usr/local/lib/python2.7/dist-packages/positional/__init__.py\", line 108, in inner\r\n    return wrapped(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keystoneauth1/identity/base.py\", line 428, in get_discovery\r\n    authenticated=authenticated)\r\n  File \"/usr/local/lib/python2.7/dist-packages/positional/__init__.py\", line 108, in inner\r\n    return wrapped(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keystoneauth1/discover.py\", line 1164, in get_discovery\r\n    disc = Discover(session, url, authenticated=authenticated)\r\n  File \"/usr/local/lib/python2.7/dist-packages/positional/__init__.py\", line 108, in inner\r\n    return wrapped(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keystoneauth1/discover.py\", line 402, in __init__\r\n    authenticated=authenticated)\r\n  File \"/usr/local/lib/python2.7/dist-packages/positional/__init__.py\", line 108, in inner\r\n    return wrapped(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keystoneauth1/discover.py\", line 101, in get_version_data\r\n    resp = session.get(url, headers=headers, authenticated=authenticated)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keystoneauth1/session.py\", line 845, in get\r\n    return self.request(url, 'GET', **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/positional/__init__.py\", line 108, in inner\r\n    return wrapped(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keystoneauth1/session.py\", line 703, in request\r\n    resp = send(**kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keystoneauth1/session.py\", line 777, in _send_request\r\n    raise exceptions.ConnectFailure(msg)\r\nkeystoneauth1.exceptions.connection.ConnectFailure: Unable to establish connection to http://10.0.11.100:5000: ('Connection aborted.', BadStatusLine(\"''\",))\r\n", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

我已经测试过10.0.11.100:5000可从实用程序容器中获取。我不确定是什么会导致Unable与http://10.0.11.100:5000建立连接:('连接已中止。',BadStatusLine(\“''\”,))\ r \ n“。

我也很惊讶它尝试连接到我的外部vip:5000而不是cloud.yml文件中定义的内部authurl:172.29.236.10:5000

任何关于寻找什么的想法都会非常受欢迎。

1 个答案:

答案 0 :(得分:0)

除非特别指定,否则os_modules似乎会抓取并使用公共端点。通过为openstack模块提供参数/值“endpoint_type:internal”,问题似乎在我的OAD openstack部署中得到解决。