Add protection against no local facts being defined

If there are no local facts, the initialisation of
facts fails due to ansible_local being undefined.

This patch adds a conditional for that situation and
als makes the task set slightly more code-efficient.

Change-Id: I605280fb3ccd0f12b32bb572b064b9b04109934b
This commit is contained in:
Jesse Pretorius 2017-06-24 07:24:46 +01:00
parent cf5ae701de
commit 2d4719fd7d
1 changed files with 12 additions and 27 deletions

View File

@ -13,28 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Initialize the wheel build local fact
- name: Initialize local facts
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: repo_build
option: need_wheel_build
option: "{{ item }}"
value: False
with_items:
- "need_wheel_build"
- "need_venv_build"
when:
- "('openstack_ansible' not in ansible_local) or
- "('ansible_local' is not defined) or
('openstack_ansible' not in ansible_local) or
('repo_build' not in ansible_local['openstack_ansible']) or
('need_wheel_build' not in ansible_local['openstack_ansible']['repo_build'])"
- name: Initialize the venv build local fact
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: repo_build
option: need_venv_build
value: False
when:
- "('openstack_ansible' not in ansible_local) or
('repo_build' not in ansible_local['openstack_ansible']) or
('need_venv_build' not in ansible_local['openstack_ansible']['repo_build'])"
- name: Create package directories
file:
path: "{{ item }}"
@ -72,28 +65,20 @@
dest: "{{ repo_build_release_path }}/requirements_constraints.txt"
register: _wheel_build_constraints
- name: Record whether a wheel build is required
- name: Record whether a wheel/venv build is required
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: repo_build
option: need_wheel_build
option: "{{ item }}"
value: True
with_items:
- "need_wheel_build"
- "need_venv_build"
when:
- (_wheel_build_requirements | changed) or
(_wheel_build_constraints | changed) or
(repo_build_wheel_rebuild | bool)
- name: Record whether a venv build is required
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: repo_build
option: need_venv_build
value: True
when:
- (_wheel_build_requirements | changed) or
(_wheel_build_constraints | changed) or
(repo_build_venv_rebuild | bool)
- name: Install pip packages
pip:
name: "{{ repo_pip_packages }}"