我尝试使用ansible在ubuntu中自动化openstack istallation。对于身份服务(keystone安装),
我的任务是创建用户“demo”,执行此操作的命令是
openstack user create --domain default --password-prompt demo
我正在使用os_user模块, https://docs.ansible.com/ansible/os_user_module.html用于创建用户。
- os_user:
name: demo
password: DEMO_PASS
domain: default
wait: yes
state: present
environment: "{{ admin_openrc }}"
主持人是,
- hosts: controller
roles:
- install_keystone
tags:
- keystone
vars:
admin_openrc:
OS_PROJECT_DOMAIN_NAME: Default
OS_USER_DOMAIN_NAME: Default
OS_PROJECT_NAME: admin
OS_USERNAME: admin
OS_PASSWORD: ADMIN_PASS
OS_AUTH_URL: http://controller:35357/v3
OS_IDENTITY_API_VERSION: 3
OS_IMAGE_API_VERSION: 2
demo_openrc:
OS_PROJECT_DOMAIN_NAME: Default
OS_USER_DOMAIN_NAME: Default
OS_PROJECT_NAME: demo
OS_USERNAME: demo
OS_PASSWORD: DEMO_PASS
OS_AUTH_URL: http://controller:5000/v3
OS_IDENTITY_API_VERSION: 3
OS_IMAGE_API_VERSION: 2
但是当我运行剧本时,我得到以下错误,
"msg": "Failed to list users"
并且模块因错误而失败。
当我直接在终端中运行命令时,它工作正常。
请帮助我。
答案 0 :(得分:0)
你可以尝试:
vars:
auth_dict:
password: admin-pw
auth_url: http://your-url/your-version
username: admin
使用auth参数与os_user:
tasks:
- os_user:
auth: '{{ auth_dict }}'
name: your-user
password: your-password