Score:0

why ansible_facts['distribution']=="Suse" skipping apache install on Suse

vc flag

I created the simple ansible playbook to install apache on CentOS and Suse. It works on CentOS but skipping on Suse without any errors, I do not understand why.

This is the playbook:

  • name: To install Apache on CentOS and Suse hosts: all gather_facts: True become: yes become_user: root

tasks:
  - name: Installing Apache on CentOS or RedHat
    yum:
      name: httpd
      state: latest
    when: ansible_facts['distribution']=="CentOS" or ansible_facts['distribution']=="Red Hat Enterprise Linux"

  - name: Installing Apache on Suse
    zypper:
      name: apache2
      state: latest
    when: ansible_facts['distribution']=="Suse" or ansible_facts['distribution']=="SLES"
in flag
use the [`debug`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html) module and check the actual value of `ansible_facts['distribution']`.
emp0001 avatar
vc flag
I added: register and debug for both and then for both I got: VARIABLE IS NOT DEFINED!
in flag
There is your answer why it's not working. Inspect `ansible_facts` and find an attribute that exists.
emp0001 avatar
vc flag
ok, thank you that works
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.