On 21. april 2017 17:50, Cary Anderson wrote:
I am having a problem with a role that I am working on to install rpm's on
a rhel server.  If a package in the list is not found, the playbook fails
to install any of the packages.  Is there a way to work around this outside
of only including available rpm's in my list?  I know that the osad package
is not in the current repos, but my expectation was that it would simply
fail and move on to the next package in the list, not fail the entire list.
 Is there error handling that would address this?

This is the main.yml task for the role:
/etc/ansible/roles/install-base-packages

---
- name: Add the OS Major Release specific variables
  include_vars: 'rhel{{ ansible_distribution_major_version }}.yml'
  tags: [ 'common', 'lst-rpm-base' ]

- name: Install the required LST base packages
  yum: name="{{ item }}" state=present
  with_items: "{{ rpm_base_pkgs }}"
  tags: [ 'common', 'lst-rpm-base' ]


This is my role var file for rhel6 servers:
/etc/ansible/roles/install-base-packages/vars/rhel6.yml

rpm_base_pkgs:
  - lvm2
  - net-tools
  - ksh
  - lsscsi
  - nmap
  - nc
  - osad
  - oddjob-mkhomedir
  - oddjob
...


If the yum is anything like the apt module it takes all the entries in the list and make one yum command
yum install lvm2 net-tools .....

I don't now if it's possible to turn this behavior off, but a workaround like this will work.

inc.yml
---
- yum: name={{ item }}
  ignore_errors: yes


install.yml
---
- include: inc.yml
  with_items: '{{ rpm_base_pkgs }}'


--
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/5bd02272-e05c-e278-5f30-e748f9de9237%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to