On 01. sep. 2016 18:02, ZillaYT wrote:
> I'm writing a role to configure syslog, and of course the service is
> different between Linux instances. How do I do this in var/main.yml?
The directory must be vars not var.
> # pseudo-code in vars/main.yml
> if Redhat7.x
> syslog_service: rsyslog
> else if RedHat6.x
> syslog_service: syslog
> end
It's not possible, vars/main.yml can only contain variable definitions,
not logic.
> So then I can just do this in tasks/main.yml
>
> - name: Ensure syslog is running
> service: name="{{ syslog_service }}" state=running enabled=yes
You must split it in two tasks.
ansible_os_family and ansible_lsb.major_release values is probably wrong
so you need to find the correct ones.
- name: Ensure syslog is running on Redhat 6.x
service: name=syslog state=running enabled=yes
when: ansible_os_family == "RedHat" and ansible_lsb.major_release == "6"
- name: Ensure syslog is running on Redhat 7.x
service: name=rsyslog state=running enabled=yes
when: ansible_os_family == "RedHat" and ansible_lsb.major_release == "7"
--
Kai Stian Olstad