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

46 lines
1.3 KiB
YAML

# We're going to want to store things in `working_dir` so ensure it
# exists first. `working_dir` is a directory on the target host.
- name: Ensure remote working dir exists
file:
path: "{{ working_dir }}"
state: directory
# 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"
- name: Read virt_power private key
set_fact:
virt_power_key_pvt: "{{ item }}"
with_file:
- "{{ virt_power_key }}"
- name: add virt_power_key to remote authorized_keys
authorized_key:
user: "{{ ansible_user_id }}"
key: "{{ item }}"
manage_dir: true
with_file:
- "{{ virt_power_key }}.pub"