tripleo-quickstart/roles/libvirt/setup/user/tasks/main.yml

46 lines
1.3 KiB
YAML

# Also make sure `local_working_dir` exists. This is a directory on
# the ansible control host.
- name: Ensure local working dir exists
delegate_to: localhost
file:
path: "{{ local_working_dir }}"
state: directory
# Create ssh keypairs. `virt_power_key` is used by ironic on the
# undercloud to control libvirt on the physical host, and
# `undercloud_key` is used to log in to the undercloud.
- name: Generate ssh keys
delegate_to: localhost
command: >
ssh-keygen -f '{{ item.path }}' -N ''
-C '{{ item.comment }}'
-t rsa -b 4096
args:
creates: "{{ item.path }}"
with_items:
- path: "{{ virt_power_key }}"
comment: "ansible_generated_virt_power"
- path: "{{ undercloud_key }}"
comment: "ansible_generated_undercloud"
# Copy the undercloud key to the virthost in the ssh_user directory
- name: copy ssh keys to virthost
copy:
src: "{{ undercloud_key }}"
dest: "{{ working_dir }}"
owner: "{{ ssh_user }}"
group: "{{ ssh_user }}"
mode: 0600
- name: Read virt_power private key
no_log: True
set_fact:
virt_power_key_pvt: "{{ lookup('file', virt_power_key)|default('') }}"
- name: add virt_power_key to remote authorized_keys
authorized_key:
user: "{{ ansible_user_id }}"
key: "{{ lookup('file', virt_power_key|quote + '.pub')|default('') }}"
manage_dir: true