Enable idempotence test

Tasks involved in the online install of pip have been made idempotent
and the idempotence test has been enabled.

The selfcheck.json file will only be written if it does not already
exist. Blocks have been added to tasks that have a fallback if they
fail. Tasks that run commands to install or download pip packages now
check stdout for success messages to determine if they should be marked
changed.

Change-Id: I0d440efd4d95420f6f43316f5e0242b8884293c8
This commit is contained in:
Jimmy McCrory 2017-03-02 16:18:53 -08:00
parent 793ae4d013
commit 289531e46b
7 changed files with 72 additions and 66 deletions

View File

@ -45,6 +45,7 @@
owner: "{{ ansible_user_id }}"
group: "{{ ansible_group_id|default(ansible_user_id) }}"
mode: "0644"
force: no
tags:
- pip-files

View File

@ -13,44 +13,44 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Get Modern PIP to local
local_action:
module: get_url
url: "{{ pip_upstream_url }}"
dest: "/tmp/get-pip.py"
force: "yes"
validate_certs: "{{ pip_validate_certs }}"
register: get_pip_local
until: get_pip_local | success
failed_when: false
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
- name: Get Modern PIP using fallback URL to local
local_action:
module: get_url
url: "{{ pip_fallback_url }}"
dest: "/tmp/get-pip.py"
force: "yes"
validate_certs: "{{ pip_validate_certs }}"
when: get_pip_local | failed
register: get_pip_local_fallback
until: get_pip_local_fallback | success
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
- block:
- name: Get Modern PIP to local
local_action:
module: get_url
url: "{{ pip_upstream_url }}"
dest: "/tmp/get-pip.py"
force: "yes"
validate_certs: "{{ pip_validate_certs }}"
register: get_pip_local
until: get_pip_local | success
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
rescue:
- name: Get Modern PIP using fallback URL to local
local_action:
module: get_url
url: "{{ pip_fallback_url }}"
dest: "/tmp/get-pip.py"
force: "yes"
validate_certs: "{{ pip_validate_certs }}"
when: get_pip_local | failed
register: get_pip_local_fallback
until: get_pip_local_fallback | success
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
- name: Create local pip package cache
local_action:
@ -66,7 +66,7 @@
- name: pip cache install files locally
local_action: >
command python /tmp/get-pip.py -d '{{ pip_tmp_packages | quote }}' {{ pip_get_pip_options }} {{ pip_packages | map('quote') | join (' ') }}
changed_when: false
changed_when: pip_local_cache.stdout.find('Successfully downloaded') != -1
register: pip_local_cache
until: pip_local_cache | success
retries: 3

View File

@ -13,32 +13,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Get Modern PIP
get_url:
url: "{{ pip_upstream_url }}"
dest: "/opt/get-pip.py"
force: "{{ pip_get_pip_force | bool }}"
validate_certs: "{{ pip_validate_certs }}"
register: get_pip
until: get_pip | success
failed_when: false
retries: 5
delay: 2
tags:
- pip-install-script
- block:
- name: Get Modern PIP
get_url:
url: "{{ pip_upstream_url }}"
dest: "/opt/get-pip.py"
force: "{{ pip_get_pip_force | bool }}"
validate_certs: "{{ pip_validate_certs }}"
register: get_pip
until: get_pip | success
retries: 5
delay: 2
tags:
- pip-install-script
- name: Get Modern PIP using fallback URL
get_url:
url: "{{ pip_fallback_url }}"
dest: "/opt/get-pip.py"
force: "{{ pip_get_pip_force | bool }}"
validate_certs: "{{ pip_validate_certs }}"
when: get_pip | failed
register: get_pip_fallback
until: get_pip_fallback | success
retries: 5
delay: 2
tags:
- pip-install-script
rescue:
- name: Get Modern PIP using fallback URL
get_url:
url: "{{ pip_fallback_url }}"
dest: "/opt/get-pip.py"
force: "{{ pip_get_pip_force | bool }}"
validate_certs: "{{ pip_validate_certs }}"
when: get_pip | failed
register: get_pip_fallback
until: get_pip_fallback | success
retries: 5
delay: 2
tags:
- pip-install-script
- include: install_source.yml

View File

@ -19,7 +19,7 @@
python /opt/get-pip.py {{ pip_source_install_options }}
{{ pip_get_pip_options }}
{{ pip_packages | map('quote') | join (' ') }}
changed_when: false
changed_when: pip_install.stdout.find('Successfully installed') != -1
register: pip_install
until: pip_install | success
retries: 3
@ -31,6 +31,7 @@
python /opt/get-pip.py --isolated {{ pip_source_install_options }}
{{ pip_get_pip_options }}
{{ pip_packages | map('quote') | join (' ') }}
changed_when: pip_install_fall_back.stdout.find('Successfully installed') != -1
register: pip_install_fall_back
until: pip_install_fall_back | success
retries: 3

View File

@ -54,6 +54,7 @@
--setopt="updates.priority=50"
--enable extras
--setopt="extras.priority=50"
changed_when: false
when:
- user_external_repo_key is not defined
tags:

View File

@ -34,9 +34,11 @@
- name: Get pip path
command: which pip
register: pip_path
changed_when: false
- name: Get pip version
command: "{{ pip_path.stdout }} -V"
register: pip_version
changed_when: false
- name: Check role functions
assert:
that:

View File

@ -25,7 +25,7 @@ whitelist_externals =
setenv =
PYTHONUNBUFFERED=1
ROLE_NAME=pip_install
TEST_IDEMPOTENCE=false
TEST_IDEMPOTENCE=true
VIRTUAL_ENV={envdir}
WORKING_DIR={toxinidir}