我正在使用 OpenStack ansible 模块部署到 Rackspace Cloud。
我在创建 SSH 密钥对时遇到问题。它创建公钥,并将其安装在主机上。但是我可以看到返回的 JSON 不包含 private_key 键值对。
- name: SSH key check
os_keypair:
auth:
auth_url: "{{ os_auth_url }}"
project_name: "{{ os_project_name }}"
username: "{{ os_username }}"
password: "{{ os_password }}"
state: present
region_name: "{{ os_region }}"
name: "{{ os_key_name }}"
register: keypair
- name: Create local public
local_action:
module: copy
content: "{{ keypair.key.public_key }}"
dest: "~/.ssh/{{ keypair.key.name }}.pub"
- name: Create local private key
local_action:
module: copy
content: "{{ keypair.key.private_key }}"
dest: "~/.ssh/{{ keypair.key.name }}"
ignore_errors: True
密钥对 var 的值:
{
"changed": false,
"id": "openstack",
"key": {
"public_key": "ssh-rsa AAAAByouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeyouknowwhatapublickeylookslikeJiln Generated-by-Nova",
"NAME_ATTR": "name",
"name": "openstack",
"fingerprint": "89:e9:3d:s0:m3:nu:mb:3r:41:d5:09:8b:a9:b8:50:65",
"id": "openstack",
"human_id": null,
"request_ids": [],
"HUMAN_ID": false,
"x_openstack_request_ids": []
}
}
如您所见private_key
,不存在。根据文档,它应该返回它。
对这一切都很陌生,所以要温柔:)