-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Cherry pick Tower credential fixes to stable-2.4 #36807
Conversation
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
|
Ooof. Apparently I butchered that. |
094f9d7
to
4c24ddd
Compare
4c24ddd
to
d57cc6b
Compare
@ryanpetrello Can you take a look at this and make sure it's ok? |
except ImportError: | ||
HAS_TOWER_CLI = False | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is right, because I don't think that ansible.module_utils.ansible_tower.HAS_TOWER_CLI
exists in stable-2.4
It looks to me like you need a mix of the two, something like this:
+import os
+
+from ansible.module_utils.ansible_tower import tower_argument_spec, tower_auth_config, tower_check_mode
+
try:
- import os
import tower_cli
import tower_cli.utils.exceptions as exc
from tower_cli.conf import settings
- from ansible.module_utils.ansible_tower import tower_auth_config, tower_check_mode
-
HAS_TOWER_CLI = True
except ImportError:
HAS_TOWER_CLI = False
Hey @samdoran, thank you for working on this. I'm going to pull this down and test it today. |
@wwitzel3 @AlanCoding would you two also give this some careful scrutiny and let me know if you see any issues? |
@samdoran this looks correct to me: $ cat make_cred.yml
- hosts: all
tasks:
- tower_credential:
name: FINAL TEST
organization: Default
state: present
kind: ssh
username: ryan
password: secret
ssh_key_data: "~/.ssh/id_rsa"
ssh_key_unlock: foo
tower_config_file: "test.cfg" $ pip install git+https://github.com/samdoran/ansible.git@cherry-pick/2.4/36587
$ pip install git+https://github.com/ansible/tower-cli.git
$ tower-cli --version
Tower CLI 3.2.1
$ PYTHONPATH=$VIRTUAL_ENV/lib/python2.7/site-packages ansible-playbook -i localhost, -c local make_cred.yml -v
Using /etc/ansible/ansible.cfg as config file
PLAY [all] ***********************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [tower_credential] **********************************************************************************************************************************************************************************************************************
changed: [localhost] => {"changed": true, "credential": "FINAL TEST", "failed": false, "id": 7, "state": "present"}
PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 Note that the username, password, SSH key, and keypass are all set: Also works against a Tower 3.1.5 install: # Run against a Tower 3.1.5 host
$ pip install git+https://github.com/samdoran/ansible.git@cherry-pick/2.4/36587
$ pip install git+https://github.com/ansible/tower-cli.git@v3.1.8
$ tower-cli --version
Tower CLI 3.1.8
$ PYTHONPATH=$VIRTUAL_ENV/lib/python2.7/site-packages ansible-playbook -i localhost, -c local make_cred.yml -v
Using /etc/ansible/ansible.cfg as config file
PLAY [all] ***********************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************
ok: [localhost]
TASK [tower_credential] **********************************************************************************************
changed: [localhost] => {"changed": true, "credential": "FINAL TEST", "failed": false, "id": 6, "state": "present"}
PLAY RECAP ***********************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 @AlanCoding would you mind double checking my work here? |
(cherry picked from commit 8a41233)
(cherry picked from commit 640749d)
(cherry picked from commit 9cb4b70)
(cherry picked from commit cd68552)
…nsible#36662) older versions of Tower (3.1) don't have a concept of CredentialTypes (this was introduced in Tower 3.2). This change detects older versions of pre-3.2 tower-cli that *only* support the deprecated `kind` attribute. (cherry picked from commit 641f8b4)
…sible#36908) (cherry picked from commit a820439)
) (cherry picked from commit 0e7106b)
6b3729c
to
6c7c972
Compare
shipit |
indeed |
SUMMARY
Cherry pick #36587, #36662, #36908, and #36917 into
stable-2.4
.There were multiple merge conflicts that I resolved by hand. This needs to be approved by @ryanpetrello and/or @wenottingham before it is ok to merge.
ISSUE TYPE
COMPONENT NAME
tower_credential.py
ANSIBLE VERSION