openstack-ansible-os_octavia/tasks/octavia_keypair.yml
Dmitriy Rabotyagov d94e57f17b Fix linters and metadata
With update of ansible-lint to version >=6.0.0 a lot of new
linters were added, that enabled by default. In order to comply
with linter rules we're applying changes to the role.

With that we also update metdata to reflect current state.

Change-Id: Id8215882ee528d4c3055479e770c7432616649ba
2023-07-17 15:38:00 +02:00

51 lines
1.8 KiB
YAML

---
# Copyright 2018, VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Create keypair
register: _octavia_keypair
openstack.cloud.keypair:
auth:
auth_url: "{{ keystone_service_adminurl }}"
username: "{{ octavia_service_user_name }}"
password: "{{ octavia_service_password }}"
project_name: "{{ octavia_service_project_name }}"
user_domain_name: "{{ octavia_service_user_domain_id }}"
project_domain_name: "{{ octavia_service_project_domain_id }}"
state: "{{ (octavia_ssh_enabled | bool) | ternary('present', 'absent') }}"
interface: admin
verify: "{{ not keystone_service_adminuri_insecure }}"
name: "{{ octavia_ssh_key_name }}"
delegate_to: "{{ octavia_keypair_setup_host }}"
vars:
ansible_python_interpreter: "{{ octavia_keypair_setup_host_python_interpreter }}"
- name: Write private key locally
copy:
content: "{{ _octavia_keypair['keypair']['private_key'] }}"
dest: "{{ lookup('env', 'HOME') }}/.ssh/{{ octavia_ssh_key_name }}"
mode: "0600"
delegate_to: localhost
when:
- _octavia_keypair is changed
- octavia_ssh_enabled
- name: Remove private key from deploy host after use
file:
path: "{{ lookup('env', 'HOME') }}/.ssh/{{ octavia_ssh_key_name }}"
state: absent
delegate_to: localhost
when:
- not octavia_ssh_enabled