Inherit calling Ansible's environment when running ceph-ansible
When config-download runs ceph-ansible it does so by calling Ansible from within Ansible. This change adds a new boolean, ceph_ansible_inherits_calling_ansible_environment (default: true), which passes all ANSIBLE_* environment variables to the nested Ansible execution. If a config-download user exported a variable, e.g. ANSIBLE_PRIVATE_KEY_FILE, then they might be surprised if they got to the Ceph installation and it failed because Ansible was unable to SSH into the target nodes because it didn't have that environment variable set. Rather than require the user to know about the nested execution and use the CephAnsibleEnvironmentVariables parameter, assume they want the same variables passed. Required TripleO defaults for ceph-ansible still take precedence over config-download environment variables; ANSIBLE_ROLES_PATH still refers to ceph-ansible roles, not config-download roles. CephAnsibleEnvironmentVariables takes precedence over both the calling Ansible environment variables and TripleO defaults for ceph-ansible. Change-Id: I428f6deb416b540dae552b5fc7a778cbc7505e8c
This commit is contained in:
parent
81029211d4
commit
eca6cd03e7
@ -144,3 +144,4 @@ openstack_config: true
|
||||
pools: []
|
||||
ntp_service_enabled: false
|
||||
generate_fsid: false
|
||||
ceph_ansible_inherits_calling_ansible_environment: true
|
||||
|
@ -43,3 +43,22 @@
|
||||
ansible_user_dir: "{{ lookup('env', 'HOME') }}"
|
||||
when:
|
||||
- ansible_user_dir is undefined
|
||||
|
||||
- name: set default for calling_ansible_environment_variables
|
||||
set_fact:
|
||||
calling_ansible_environment_variables: []
|
||||
|
||||
- when: ceph_ansible_inherits_calling_ansible_environment
|
||||
block:
|
||||
- name: get all ansible environment variables
|
||||
shell: "env | grep ANSIBLE_"
|
||||
register: env_shell_output
|
||||
ignore_errors: true
|
||||
- name: set calling_ansible_environment_variables
|
||||
set_fact:
|
||||
calling_ansible_environment_variables: "{{ env_shell_output.stdout_lines }}"
|
||||
when:
|
||||
- env_shell_output.rc is defined
|
||||
- env_shell_output.rc == 0
|
||||
- env_shell_output.stdout_lines is defined
|
||||
- (env_shell_output.stdout_lines|length) > 0
|
||||
|
@ -26,6 +26,7 @@
|
||||
- name: set ceph-ansible command list
|
||||
set_fact:
|
||||
ceph_ansible_command_list:
|
||||
- "{{ calling_ansible_environment_variables|join(' ') }}"
|
||||
- ANSIBLE_ACTION_PLUGINS=/usr/share/ceph-ansible/plugins/actions/
|
||||
- ANSIBLE_CALLBACK_PLUGINS=/usr/share/ceph-ansible/plugins/callback/
|
||||
- ANSIBLE_ROLES_PATH=/usr/share/ceph-ansible/roles/
|
||||
|
@ -17,6 +17,7 @@
|
||||
- name: build nodes-uuid command as list
|
||||
set_fact:
|
||||
nodes_uuid_list:
|
||||
- "{{ calling_ansible_environment_variables|join(' ') }}"
|
||||
- ANSIBLE_LOG_PATH="{{ playbook_dir }}/ceph-ansible/nodes_uuid_command.log"
|
||||
- ANSIBLE_SSH_CONTROL_PATH_DIR="{{ playbook_dir }}/ceph-ansible/"
|
||||
- ANSIBLE_CONFIG="{{ playbook_dir }}/ansible.cfg"
|
||||
|
Loading…
Reference in New Issue
Block a user