I've been getting my feet wet with Ansible (2.0.0.2) on CentOS 7. I'm trying to obtain a version from an installed rpm/yum package, but ran into a warning message when running the script.
Ansible script:
---
- name: Get version of RPM
shell: yum list installed custom-rpm | grep custom-rpm | awk '{print $2}' | cut -d'-' -f1
register: version
changed_when: False
- name: Update some file with version
lineinfile:
dest: /opt/version.xml
regexp: "<version>"
line: " <version>{{ version.stdout }}</version>"
Running this works fine and does what it's supposed to, but it's returning a warning after it executes:
ok: [default] => {"changed": false, "cmd": "yum list installed custom-rpm | grep custom-rpm | awk '{print $2}' | cut -d'-' -f1", "delta": "0:00:00.255406", "end": "2016-05-17 23:11:54.998838", "rc": 0, "start": "2016-05-17 23:11:54.743432", "stderr": "", "stdout": "3.10.2", "stdout_lines": ["3.10.2"], "warnings": ["Consider using yum module rather than running yum"]}
[WARNING]: Consider using yum module rather than running yum
I looked up information for the yum module on the Ansible site, but I don't really want to install/update/delete anything.
I could simply ignore it or suppress it, but I was curious if there was a better way?