openshift-ansible: Inconsistent openshift_release values detailed in aws deployment and openshift-ansible example inventory file

Description

I have been peer reviewing AWS deployment code getting ready to integrate the procedure into the e2e reference documentation. I’ve come across a situation where we set a vars file containing key openshift_release.

I would expect this key to align with the values in an openshift-ansible inventory file so that it’s not being defined twice, overwritten or overridden and creating a race or error condition.

Version
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)
$ ansible --version
ansible 2.4.1.0
  config file = /home/ccallega/git/openshift-ansible/ansible.cfg
  configured module search path = [u'/home/ccallega/git/openshift-ansible/library']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, May  3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]
$ git describe
openshift-ansible-3.9.0-0.6.0-3-g34d8433b0
Steps To Reproduce
  1. cd ~/git/openshift-ansible/playbooks/aws/openshift-cluster
  2. Use openshift-ansible config file…
ANSIBLE_CONFIG=$HOME/git/openshift-ansible/ansible.cfg
  1. Set AWS provisioning vars file like so…
cat > provisioning_vars.yml << EOF
# Minimum mandatory provisioning variables.  See provisioning_vars.yml.example.
# for more information.
ansible_ssh_user: ec2-user
openshift_deployment_type: openshift-enterprise
openshift_release: v3.7 # This value aligns with openshift-ansible inventory file
openshift_pkg_version: -3.7.0
openshift_aws_clusterid: blah
openshift_aws_ssh_key_name: ccallegar
openshift_aws_base_ami: ami-fbc89880
rhel_subscription_user: 'user@example.com'
rhel_subscription_pass: 'abcd1234'
rhel_subscription_pool: 'abcd1234'
EOF
  1. Run play…
$ ansible-playbook -i inventory.yml build_ami.yml -e @provisioning_vars.yml
Expected Results

I expect build_ami.yml to complete without errors.

Observed Results

Ansible play fails…

TASK [openshift_sanitize_inventory : Abort when openshift_release is invalid] *******************************************************
Wednesday 13 December 2017  13:38:22 -0500 (0:00:00.068)       0:00:08.693 ****
fatal: [ec2-52-91-185-153.compute-1.amazonaws.com]: FAILED! => {"changed": false, "failed": true, "msg": "openshift_release is \"v3.7\" which is not a valid version string.\nPlease set it to a version string like \"3.4\"."}

PLAY RECAP **************************************************************************************************************************
127.0.0.1                  : ok=15   changed=1    unreachable=0    failed=0
ec2-52-91-185-153.compute-1.amazonaws.com : ok=9    changed=0    unreachable=0    failed=1


INSTALLER STATUS ********************************************************************************************************************
Initialization             : In Progress (0:00:05)

Wednesday 13 December 2017  13:38:22 -0500 (0:00:00.054)       0:00:08.748 ****
===============================================================================
openshift_sanitize_inventory : Check for usage of deprecated variables ------------------------------------------------------- 1.67s
openshift_aws : create instance for ami creation ----------------------------------------------------------------------------- 0.91s
openshift_aws : fetch newly created instances -------------------------------------------------------------------------------- 0.77s
openshift_aws : fetch the default subnet id ---------------------------------------------------------------------------------- 0.62s
openshift_aws : query vpc ---------------------------------------------------------------------------------------------------- 0.60s
openshift_sanitize_inventory : conditional_set_fact -------------------------------------------------------------------------- 0.46s
openshift_sanitize_inventory : conditional_set_fact -------------------------------------------------------------------------- 0.36s
openshift_aws : wait for ssh to become available ----------------------------------------------------------------------------- 0.31s
Run openshift_sanitize_inventory to set variables ---------------------------------------------------------------------------- 0.19s
create an instance and prepare for ami --------------------------------------------------------------------------------------- 0.17s
openshift_sanitize_inventory : Assign deprecated variables to correct counterparts ------------------------------------------- 0.15s
Evaluate oo_all_hosts -------------------------------------------------------------------------------------------------------- 0.13s
Evaluate oo_etcd_to_migrate -------------------------------------------------------------------------------------------------- 0.12s
set the user to perform installation ----------------------------------------------------------------------------------------- 0.10s
openshift_sanitize_inventory : include_tasks --------------------------------------------------------------------------------- 0.10s
Evaluate oo_nodes_to_config -------------------------------------------------------------------------------------------------- 0.10s
Evaluate oo_glusterfs_to_config ---------------------------------------------------------------------------------------------- 0.09s
openshift_sanitize_inventory : set_fact -------------------------------------------------------------------------------------- 0.08s
openshift_aws : include_tasks ------------------------------------------------------------------------------------------------ 0.07s
Alert user to variables needed and their values - {{ item.name }} ------------------------------------------------------------ 0.07s
Additional Information

v3.7 IS a valid OpenShift version. openshift-ansible hosts.example inventory file advertises the correct as v3.[0-9]+. I would say that “TASK [openshift_sanitize_inventory : Abort when openshift_release is invalid” is not doing the needful.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (11 by maintainers)

Most upvoted comments

The problem appears to be caused by the following file… /Users/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yaml

37	- name: Normalize openshift_release
38	  set_fact:
39	    # Normalize release if provided, e.g. "v3.5" => "3.5"
40	    # Currently this is not required to be defined for all installs, and the
41	    # `openshift_version` role can generally figure out the specific version
42	    # that gets installed (e.g. 3.5.0.1). So consider this the user's expressed
43	    # intent (if any), not the authoritative version that will be installed.
44	    openshift_release: "{{ openshift_release | string | regex_replace('^v', '') }}"
45	  when: openshift_release is defined
46
47	- name: Abort when openshift_release is invalid
48	  when:
49	    - openshift_release is defined
50	    - not (openshift_release is match('^\d+(\.\d+){1,3}$'))
51	  fail:
52	    msg: |-
53	      openshift_release is "{{ openshift_release }}" which is not a valid version string.
54	      Please set it to a version string like "3.4".

Scenario 1 : ‘openshift_release: v3.7’ - Fails Task ‘Normalize openshift_release’ is being casted to a string. The v gets removed but it appears the local fact isn’t being pushed up to the Ansible global inventory. Task ‘Abort when openshift_release is invalid’ causes failure because match() finds the v in the value of openshift_release.

TASK [openshift_sanitize_inventory : Normalize openshift_release] ********************************************************************
task path: /home/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yml:37
Tuesday 19 December 2017  16:09:45 -0500 (0:00:00.204)       0:00:36.248 ******
ok: [ec2-54-210-102-140.compute-1.amazonaws.com] => {
    "ansible_facts": {
        "openshift_release": "3.7"
    },
    "changed": false,
    "failed": false
}
ok: [ec2-54-210-90-131.compute-1.amazonaws.com] => {
    "ansible_facts": {
        "openshift_release": "3.7"
    },
    "changed": false,
    "failed": false
}
ok: [ec2-54-144-168-196.compute-1.amazonaws.com] => {
    "ansible_facts": {
        "openshift_release": "3.7"
    },
    "changed": false,
    "failed": false
}

TASK [openshift_sanitize_inventory : Abort when openshift_release is invalid] ********************************************************
task path: /home/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yml:47
Tuesday 19 December 2017  16:09:45 -0500 (0:00:00.272)       0:00:36.520 ******
fatal: [ec2-54-210-102-140.compute-1.amazonaws.com]: FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "openshift_release is \"v3.7\" which is not a valid version string.\nPlease set it to a version string like \"3.4\"."
}
fatal: [ec2-54-210-90-131.compute-1.amazonaws.com]: FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "openshift_release is \"v3.7\" which is not a valid version string.\nPlease set it to a version string like \"3.4\"."
}
fatal: [ec2-54-144-168-196.compute-1.amazonaws.com]: FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "openshift_release is \"v3.7\" which is not a valid version string.\nPlease set it to a version string like \"3.4\"."
}

Scenario 2 : ‘openshift_release: 3.7’ - Fails I really don’t know why we fail here. L37 & L47 look good to me. It looks like the value is getting casted to a string in task at L37. L47 fails because of a digit to string mismatch.

TASK [openshift_sanitize_inventory : Normalize openshift_release] ********************************************************************
task path: /home/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yml:37
Tuesday 19 December 2017  16:13:16 -0500 (0:00:00.220)       0:00:37.371 ******
ok: [ec2-54-210-102-140.compute-1.amazonaws.com] => {
    "ansible_facts": {
        "openshift_release": "3.7"
    },
    "changed": false,
    "failed": false
}
ok: [ec2-54-210-90-131.compute-1.amazonaws.com] => {
    "ansible_facts": {
        "openshift_release": "3.7"
    },
    "changed": false,
    "failed": false
}
ok: [ec2-54-144-168-196.compute-1.amazonaws.com] => {
    "ansible_facts": {
        "openshift_release": "3.7"
    },
    "changed": false,
    "failed": false
}

TASK [openshift_sanitize_inventory : Abort when openshift_release is invalid] ********************************************************
task path: /home/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yml:47
Tuesday 19 December 2017  16:13:17 -0500 (0:00:00.300)       0:00:37.672 ******
fatal: [ec2-54-210-102-140.compute-1.amazonaws.com]: FAILED! => {
    "failed": true,
    "msg": "The conditional check 'not (openshift_release is match('^\\d+(\\.\\d+){1,3}$'))' failed. The error was: Unexpected templating type error occurred on ({% if not (openshift_release is match('^\\d+(\\.\\d+){1,3}$')) %} True {% else %} False {% endif %}): expected string or buffer\n\nThe error appears to have been in '/home/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yml': line 47, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Abort when openshift_release is invalid\n  ^ here\n"
}
fatal: [ec2-54-210-90-131.compute-1.amazonaws.com]: FAILED! => {
    "failed": true,
    "msg": "The conditional check 'not (openshift_release is match('^\\d+(\\.\\d+){1,3}$'))' failed. The error was: Unexpected templating type error occurred on ({% if not (openshift_release is match('^\\d+(\\.\\d+){1,3}$')) %} True {% else %} False {% endif %}): expected string or buffer\n\nThe error appears to have been in '/home/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yml': line 47, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Abort when openshift_release is invalid\n  ^ here\n"
}
fatal: [ec2-54-144-168-196.compute-1.amazonaws.com]: FAILED! => {
    "failed": true,
    "msg": "The conditional check 'not (openshift_release is match('^\\d+(\\.\\d+){1,3}$'))' failed. The error was: Unexpected templating type error occurred on ({% if not (openshift_release is match('^\\d+(\\.\\d+){1,3}$')) %} True {% else %} False {% endif %}): expected string or buffer\n\nThe error appears to have been in '/home/ccallega/git/openshift-ansible/roles/openshift_sanitize_inventory/tasks/main.yml': line 47, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Abort when openshift_release is invalid\n  ^ here\n"
}

Scenario 3 : 'openshift_release: ‘3.7’ - Success Explicitly setting the value to a string in the inventory file isn’t advertised anywhere. We should fix the code to suit examples and documentation.