redhat-cop / openshift-applier

Used to apply OpenShift objects to an OpenShift Cluster
Apache License 2.0
102 stars 61 forks source link

Fix python3 imports and url checking logic #97

Closed etsauer closed 5 years ago

etsauer commented 5 years ago

What does this PR do?

Refactor url checking so that it doesn't rely on the internet

How should this be tested?

Run molecule

Is there a relevant Issue open for this?

91

Who would you like to review this?

cc: @redhat-cop/openshift-applier

tylerauerbeck commented 5 years ago

@etsauer @oybed @pcarney8 Not sure that this is working well with params_from_vars:

Running: ansible-playbook -i inventory secrets.yml --ask-vault-pass

Current error:

TASK [openshift-applier/roles/openshift-applier : Fail if template but no params is specified] ***********************************
fatal: [secrets-and-keys]: FAILED! => {"changed": false, "msg": "Template specified, but no params file supplied"}

Inventory:

bitbucket:
  USERNAME: "{{ bitbucket_username }}"
  PASSWORD: "{{ bitbucket_password }}"
  SECRET_NAME: "bitbucket-user-pass"

openshift_cluster_content:
- object: secrets
  content:
  - name: bitbucket-app-username-password
    template: "https://bitbucket.org/company/openshift-templates/raw/v1.5/templates/secrets/secret-user-pass-template.yml"
    params_from_vars: "{{ bitbucket }}"
    namespace: "{{ ci_cd.NAMESPACE }}"
    tags:
    - ci-cd
    - bit-user-pass

Current playbook:

---
- name: Create secrets
  hosts: secrets
  tasks:
    - include_vars: "{{ playbook_dir }}/secrets/user-pass.yml"
    - include_role:
        name: openshift-applier/roles/openshift-applier

I'm hoping I might just be missing something, but let me know what you think.

oybed commented 5 years ago

@tylerauerbeck are you sure you're running the correct branch (or tag)? The error you are seeing doesn't exist in the latest version of the repo + I know we had this issue 4-5 months ago, but has since been corrected. Hence, I suspect that maybe it's not using the correct version of this repo.

tylerauerbeck commented 5 years ago

@oybed Ahh -- yepp, this was me screwing up the requirements file. I fixed this and made it a bit farther -- but now I'm seeing this :

NameError: global name 'urlopen' is not defined

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

For reference on the ansible version:

ansible 2.7.0
  config file = /Users/tylerauerbeck/workspace/ci-cd/ansible.cfg
  configured module search path = [u'/Users/tylerauerbeck/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.15 (default, Oct  2 2018, 11:47:18) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.2)]
tylerauerbeck commented 5 years ago

@etsauer @oybed @pcarney8 After testing this out a bit further -- these were some self-inflicted issues. This runs without issue after fixing some of my mistakes on Fedora. I'm still seeing the urlopen error above on my mac, but I think we can chalk that up to mac/local machine errors instead of an error with the applier.

oybed commented 5 years ago

@tylerauerbeck you are correct that this doesn't work for python2 (including with our openshift-applier container). @etsauer Can you please look to fix the support for python2?

etsauer commented 5 years ago

@oybed @tylerauerbeck fixed.