keypair: copy key to deploy host rather than setup host
The env lookup in the key copying task refers to the deploy host. If your deploy host user is not root then this task will fail as this directory does not exist on the remote setup host. As the original intention appears to have been to copy the result of the keypair generation to the deploy host, the delegation is explicitly set to 'localhost'. Change-Id: I89649503d5918c33f0d1e4200be67be5e0ed8a9e
This commit is contained in:
parent
94e59adeeb
commit
ffac17201a
@ -13,38 +13,37 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Create keypair for Octavia
|
||||
- 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 }}"
|
||||
block:
|
||||
- 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 }}"
|
||||
|
||||
- name: Write private key locally
|
||||
copy:
|
||||
content: "{{ _octavia_keypair.key.private_key }}"
|
||||
dest: "{{ lookup('env', 'HOME') }}/.ssh/{{ octavia_ssh_key_name }}"
|
||||
when:
|
||||
- _octavia_keypair is changed
|
||||
- octavia_ssh_enabled
|
||||
- name: Write private key locally
|
||||
copy:
|
||||
content: "{{ _octavia_keypair.key.private_key }}"
|
||||
dest: "{{ lookup('env', 'HOME') }}/.ssh/{{ octavia_ssh_key_name }}"
|
||||
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
|
||||
when:
|
||||
- _octavia_keypair is changed
|
||||
- not 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
|
||||
|
Loading…
Reference in New Issue
Block a user