On 22. aug. 2016 11:52, Dan Nestor wrote:
Hello everybody, this is my first post here.
I have a playbook that includes these tasks:
- name: Staging directory exists
file:
path: "{{ staging_dir }}"
recurse: yes
state: directory
- name: "{{ java_package }} is present in staging directory"
copy:
src: "{{ java_package }}"
dest: "{{ staging_dir }}/{{ java_package }}"
- name: "{{ java_package }} is installed"
yum:
name: "{{ staging_dir }}/{{ java_package }}"
state: present
I would like to copy the file to the host only if needed, that is, the RPM
in question is not already installed. Can I do this in Ansible?
- name: Check if package is installed
command: rpm -q {{ java_package }}
register: package_installed
- block:
- name: Staging directory exists
file:
path: "{{ staging_dir }}"
recurse: yes
state: directory
- name: "{{ java_package }} is present in staging directory"
copy:
src: "{{ java_package }}"
dest: "{{ staging_dir }}/{{ java_package }}"
- name: "{{ java_package }} is installed"
yum:
name: "{{ staging_dir }}/{{ java_package }}"
state: present
when: package_installed.rc == 1
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/e27d2220-f57a-d4ad-d0f5-e184db0d8ad1%40olstad.com.
For more options, visit https://groups.google.com/d/optout.