Fix role gate tests for Ansible 2.3
In Ansible 2.3, 'ansible_user' seems to be undefined unless set within the inventory for a host. 'ansible_user_id' contains the current user running Ansible, but is only set after facts are gathered. Change-Id: Id5b76a87809f03951c954fc3d752419a673403f7
This commit is contained in:
parent
b02c3c619b
commit
b0be2e9327
@ -16,6 +16,7 @@
|
||||
- name: Execute the openstack-host role
|
||||
hosts: localhost
|
||||
connection: local
|
||||
become: true
|
||||
gather_facts: true
|
||||
pre_tasks:
|
||||
- include: "common-tasks/test-force-package-cache-update.yml"
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
- name: Playbook for configuring hosts
|
||||
hosts: localhost
|
||||
become: true
|
||||
pre_tasks:
|
||||
- include: "common-tasks/test-set-nodepool-vars.yml"
|
||||
- name: Clear iptables rules
|
||||
@ -31,6 +32,7 @@
|
||||
|
||||
- name: Playbook for configuring the LXC host
|
||||
hosts: localhost
|
||||
become: true
|
||||
roles:
|
||||
- role: "lxc_hosts"
|
||||
lxc_net_address: 10.100.100.1
|
||||
|
@ -59,12 +59,11 @@
|
||||
- name: Playbook for establishing user ssh keys
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
become: false
|
||||
tasks:
|
||||
# Shell used because facts may not be ready yet
|
||||
- name: Get user home directory
|
||||
shell: "getent passwd '{{ ansible_user }}' | cut -d':' -f6"
|
||||
shell: "getent passwd '{{ ansible_user_id }}' | cut -d':' -f6"
|
||||
register: user_home
|
||||
changed_when: false
|
||||
|
||||
@ -76,31 +75,31 @@
|
||||
file:
|
||||
path: "{{ calling_user_home }}/.ssh"
|
||||
state: directory
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
owner: "{{ ansible_user_id }}"
|
||||
group: "{{ ansible_user_id }}"
|
||||
mode: 0700
|
||||
when: ansible_user != 'root'
|
||||
when: ansible_user_id != 'root'
|
||||
|
||||
- name: Ensure user has the known private key
|
||||
copy:
|
||||
content: "{{ root_private_key }}"
|
||||
dest: "{{ calling_user_home }}/.ssh/id_rsa"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
owner: "{{ ansible_user_id }}"
|
||||
group: "{{ ansible_user_id }}"
|
||||
mode: "0600"
|
||||
when: ansible_user != 'root'
|
||||
when: ansible_user_id != 'root'
|
||||
|
||||
- name: Ensure user has the known public key
|
||||
copy:
|
||||
content: "{{ root_public_key }}"
|
||||
dest: "{{ calling_user_home }}/.ssh/id_rsa.pub"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
owner: "{{ ansible_user_id }}"
|
||||
group: "{{ ansible_user_id }}"
|
||||
mode: "0600"
|
||||
when: ansible_user != 'root'
|
||||
when: ansible_user_id != 'root'
|
||||
|
||||
- name: Ensure local user can ssh to localhost
|
||||
authorized_key:
|
||||
user: "{{ ansible_user }}"
|
||||
user: "{{ ansible_user_id }}"
|
||||
key: "{{ root_public_key }}"
|
||||
when: ansible_user != 'root'
|
||||
when: ansible_user_id != 'root'
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
- name: Prepare cinder-volumes volume group
|
||||
hosts: localhost
|
||||
become: true
|
||||
tasks:
|
||||
- name: Install lvm2 apt package
|
||||
apt:
|
||||
|
@ -1,5 +1,5 @@
|
||||
[all]
|
||||
localhost ansible_become=True
|
||||
localhost
|
||||
infra1 ansible_host=10.1.0.2 ansible_become=True ansible_user=root
|
||||
keystone1 ansible_host=10.1.0.3 ansible_become=True ansible_user=root
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user