winrm or requests is not installed: cannot import name certs with installed pywinrm
OK, something seems to be strange with python-urllib3. YUM tells me, it was not installed
fgi-dcv-depl1 root# yum install python-urllib3
Loaded plugins: aliases, changelog, fastestmirror, tmprepo, verify, versionlock
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package python-urllib3.noarch 0:1.10.2-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================================================================================================================================================================================
Installing:
python-urllib3 noarch 1.10.2-5.el7 base.xcmonthly 102 k
Transaction Summary
=======================================================================================================================================================================================================================================================================================================================================
Install 1 Package
Total download size: 102 k
Installed size: 378 k
Is this ok [y/d/N]:
So I want to install the package:
Is this ok [y/d/N]: y
Downloading packages:
python-urllib3-1.10.2-5.el7.noarch.rpm | 102 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-urllib3-1.10.2-5.el7.noarch 1/1
Error unpacking rpm package python-urllib3-1.10.2-5.el7.noarch
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname: cpio: rename
Verifying : python-urllib3-1.10.2-5.el7.noarch 1/1
Failed:
python-urllib3.noarch 0:1.10.2-5.el7
Complete!
fgi-dcv-depl1 root#
OK why that error? I've looked intop /usr/lib/python2.7/site-packages and saw, that a directory urllib3 was there. I've moved it to /tmp, after that I was able to install python-urllib3 package and everything works fine!
Java version check using ansible is getting skipped for no apparent reason
Note: below is an answer to your direct problem. Meanwhile if java was installed as a system package, I strongly suggest you have a look at the answer by @Jaay to get the version directly from package facts rather than using shell/command
This is what I get
"1.8.0_312"
As you can see, the quotes are part of the output. Hence if you debug java_installed.stdout
you get (ran on my local machine with java 11):
TASK [debug] ********************************************************************************************************************
ok: [localhost] => {
"java_installed.stdout": "\"11.0.15\""
}
A simple workaround is to read the incoming value as json. The following does the job (once again customized for my local machine to test and using the version
test as good practice)
---
- hosts: localhost
gather_facts: false
tasks:
- name: "[install] Check for Java install"
shell: "java -version 2>&1 | grep version | awk '{print $3}'"
changed_when: false
failed_when: false
register: java_installed
- name: show the raw and refactored captured var
vars:
my_msg:
- "Raw value for version is: {{ java_installed.stdout }}"
- "Refactored value for version is: {{ java_installed.stdout | from_json }}"
debug:
msg: "{{ my_msg }}"
- when: java_installed.stdout | from_json is version("11.0.15", "==")
debug:
msg: "Java 11 is installed"
- when: java_installed.stdout | from_json is not version("17.0.2", "==")
debug:
msg: "Java 17 is not installed"
and gives
PLAY [localhost] ****************************************************************************************************************
TASK [[install] Check for Java install] *****************************************************************************************
ok: [localhost]
TASK [show the raw and refactored captured var] *********************************************************************************
ok: [localhost] => {
"msg": [
"Raw value for version is: \"11.0.15\"",
"Refactored value for version is: 11.0.15"
]
}
TASK [debug] ********************************************************************************************************************
ok: [localhost] => {
"msg": "Java 11 is installed"
}
TASK [debug] ********************************************************************************************************************
ok: [localhost] => {
"msg": "Java 17 is not installed"
}
PLAY RECAP **********************************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Related Topics
How to Fix Urllib3 Runtimeerror: Requests Dependency 'Urllib3' Must Be Version >= 1.21.1, < 1.22
Cannot Get Qwindow::Fromwinid to Work Properly
How to Enter Text at Command Prompt from Shell Script Without Executing Command
How to Make Library Installed from Opam Available to Ocaml
Is There Any General Interfaces on Linux to Simulate Mouse Movements and Click
"Unknown Symbol in Module" on Module Insertion Despite Export_Symbol
Using Command Substitution Inside a Sed Script, with Arguments
What Algorithm How to Use to Generate a 48-Bit Hash for Unique MAC Addresses
Linux to Define Custom Shell Command
Single-File App with Xulrunner - Possible
How to Join Multiple Txt Files into Based on Column
Total Number of Bytes Read/Written by a Linux Process and Its Children
Lkm: Last Block Written to Device
Run Linux Command in Background and Keep Runing After Closing Ssh
Windows .Crl to .Pem for Nginx
Perl System Calls When Running as Another User Using Sudo
How to Test Your Own Linux Module
Raspberry Pi: Spi Not Working, Spi_Bcm2835 Not Showing with Lsmod