Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes/Openshift Ansible installer is not working on RHEL 7 #5501

Closed
megabreit opened this issue Dec 13, 2019 · 10 comments
Closed

Kubernetes/Openshift Ansible installer is not working on RHEL 7 #5501

megabreit opened this issue Dec 13, 2019 · 10 comments

Comments

@megabreit
Copy link
Contributor

ISSUE TYPE
  • Bug Report
SUMMARY

The Kubernetes/Openshift Ansible installer does not work on RHEL 7

ENVIRONMENT
  • AWX version: 9.0.1
  • AWX install method: openshift
  • Ansible version: 2.8.7 (from Redhat repository rhel-7-server-ansible-2.8-rpms)
  • Operating System: RHEL 7.7
  • Web Browser: none
  • Jinja2 version: python-jinja2-2.7.2-4.el7.noarch
STEPS TO REPRODUCE

oc login
ansible-playbook -i inventory install.yml -e openshift_token=$(oc whoami -t) -e openshift_user=clusteradminuser -vvv
Taget cluster is Openshift 3.11, oc binary is 3.11 too.

EXPECTED RESULTS

successfull installation

ACTUAL RESULTS

Playbook terminates:

TASK [kubernetes : Find cluster for current context] ********************************************************************************************************************
task path: /home/XXXX/src/awx/installer/roles/kubernetes/tasks/main.yml:203
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 145, in run
    res = self._execute()
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 592, in _execute
    self._task.post_validate(templar=templar)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/task.py", line 268, in post_validate
    super(Task, self).post_validate(templar)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/base.py", line 435, in post_validate
    value = templar.template(getattr(self, name))
  File "/usr/lib/python2.7/site-packages/ansible/template/__init__.py", line 584, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/site-packages/ansible/template/__init__.py", line 539, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/site-packages/ansible/template/__init__.py", line 804, in do_template
    res = j2_concat(rf)
  File "<template>", line 11, in root
  File "/usr/lib/python2.7/site-packages/jinja2/filters.py", line 740, in do_list
    return list(value)
  File "/usr/lib/python2.7/site-packages/jinja2/filters.py", line 931, in _select_or_reject
    if modfunc(func(transfunc(item))):
  File "/usr/lib/python2.7/site-packages/jinja2/filters.py", line 925, in <lambda>
    name, item, args, kwargs)
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 438, in call_test
    raise TemplateRuntimeError('no test named %r' % name)
TemplateRuntimeError: no test named 'equalto'


fatal: [localhost]: FAILED! => {
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}


PLAY RECAP **************************************************************************************************************************************************************
localhost                  : ok=24   changed=8    unreachable=0    failed=1    skipped=68   rescued=0    ignored=1

I suspect that the Jinja2 version is too old to support 'equalto'

ADDITIONAL INFORMATION
@silveiralexf
Copy link

@megabreit, I was having the exact same problem -- fixed it by removing the version I had previously installed with yum, and installed it with pip instead:

sudo yum remove ansible -y
pip install ansible --user

After that, all worked well for me -- hope it helps!

@megabreit
Copy link
Contributor Author

@fsilveir Thanks. I didn't know about the --user option. But getting pip working on RHEL 7 is always a pain. I prefer a clean install playbook :-)

@silveiralexf
Copy link

@megabreit indeed not a fun experience.... alternatively you can also try setting-up a virtualenv just for the install playbook.

@megabreit
Copy link
Contributor Author

I googled a bit for the error and tried to find how other people fixed this problem.
I created a working playbook by replacing "equalto" with "match". AWX 9.1.1 can be installed on OCP 3.11 from a RHEL 7 host with this fix.
I know that this is not exactly the same, but it's working. Maybe @wenottingham can judge whether or not this would be a "final" solution?

@megabreit
Copy link
Contributor Author

diff --git a/installer/roles/kubernetes/tasks/openshift.yml b/installer/roles/kubernetes/tasks/openshift.yml
index 9c6f8d2..c233e58 100644
--- a/installer/roles/kubernetes/tasks/openshift.yml
+++ b/installer/roles/kubernetes/tasks/openshift.yml
@@ -55,14 +55,14 @@
   set_fact:
     kube_cluster: |
       {{ (kube_config.contexts |
-          selectattr("name", "equalto", current_kube_context) |
+          selectattr("name", "match", current_kube_context) |
           list)[0].context.cluster }}
 
 - name: Find server for current context
   set_fact:
     kube_server: |
       {{ (kube_config.clusters |
-          selectattr("name", "equalto", kube_cluster|trim) |
+          selectattr("name", "match", kube_cluster|trim) |
           list)[0].cluster.server }}
 
 - name: Get kube version from api server

@blomquisg
Copy link

@megabreit can you submit a PR for this change?

@megabreit
Copy link
Contributor Author

@blomquisg @ryanpetrello Just for curiosity: Are there any more formal things to follow? Tests, checks, etc? Or is it ok to close the issue?

@ryanpetrello
Copy link
Contributor

Hey @megabreit,

We're gonna verify some things on our end, and then we'll close it out - thanks!

@blomquisg
Copy link

🎉 @megabreit thanks for the PR! 🎉

@elyezer
Copy link
Member

elyezer commented Apr 22, 2020

I've confirmed that we can install using a 3.11 OpenShift Cluster. The installation has been passing no problem for a while and therefore we can consider this as being verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants