Much better solution. Thanks!
I ended up doing this
- include_vars: "roles/syslog/vars/{{ ansible_os_family }}-{{
ansible_distribution_major_version }}.yml"
On Thursday, September 1, 2016 at 2:07:23 PM UTC-4, Allen Sanabria wrote:
>
> include_vars is your friend.
>
> For instance in tasks you
Additionally you can make syslog_service a dictionary value with keys for
the different versions:
vars/main.yml
syslog_service:
"6": syslog
"7": rsyslog
Then just do:
- name: Ensure syslog is running
service: name="{{ syslog_service[ansible_distribution_major_version] }}"
include_vars is your friend.
For instance in tasks you can say..
```yaml
- include_vars: RedHat6.yml
when: ansible_os_family == "RedHat" and ansible_lsb.major_release == "6"
- include_vars: RedHat7.yml
when: ansible_os_family == "RedHat" and ansible_lsb.major_release == "7"
```
On Thu, Sep
include_vars is your friend.
For instance in tasks/main.yml you can say..
- include_vars: RedHat6.yml
when: ansible_os_family == "RedHat" and ansible_lsb.major_release == "6"
- include_vars: RedHat7.yml
when: ansible_os_family == "RedHat" and ansible_lsb.major_release == "7"
On Thursday,
Having a lot of -name/when task blocks is just ugly infrastructure. I have
to think of a better way. There's GOT to be a better way.
On Thursday, September 1, 2016 at 1:45:02 PM UTC-4, Kai Stian Olstad wrote:
>
> On 01. sep. 2016 18:02, ZillaYT wrote:
> > I'm writing a role to configure syslog,
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
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?
# pseudo-code in vars/main.yml
if Redhat7.x
syslog_service: rsyslog
else if RedHat6.x
syslog_service: syslog
end
So then I can just do this in