]> git.phdru.name Git - ansible.git/commitdiff
Feat: Recognize OS type by `os_family`, not OS name
authorOleg Broytman <phd@phdru.name>
Sun, 1 Sep 2019 15:19:40 +0000 (18:19 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 1 Sep 2019 23:30:41 +0000 (02:30 +0300)
There are too many OS names to recognize: Debian, (K/X)Ubuntu,
CentOS, Fedora, RedHat...

playbooks/roles/adjtimex/tasks/main.yml
playbooks/roles/sshd/handlers/main.yml

index 16209b722ddb4c28a62f6e417dacc27ee40bd8d9..a7864a80c1c3547ba9abd68882c11331c3e03c44 100644 (file)
@@ -8,7 +8,7 @@
     name: ['adjtimex', 'ntpdate-debian']
     state: latest
     update_cache: yes
-  when: ansible_facts.distribution == "Debian"
+  when: ansible_facts.os_family == 'Debian'
 
 - name: Install adjtimex and ntpdate
   become: true
@@ -16,7 +16,7 @@
     name: ['adjtimex', 'ntpdate']
     state: latest
     update_cache: yes
-  when: ansible_facts.distribution != "Debian"
+  when: ansible_facts.os_family == 'RedHat'
 
 - name: Copy the script adjtimex.sh
   become: true
index 264fd314a50a8545dc730f2d868d32eb0c9ddaf1..b7beb0a35cb92686f4f9aa6a7163800ece47f352 100644 (file)
@@ -1,5 +1,5 @@
 - name: Reload sshd
   become: true
   service:
-    name: "ssh{{ ansible_facts.distribution != 'Debian' and 'd' or '' }}"
+    name: "ssh{{ ansible_facts.os_family == 'RedHat' and 'd' or '' }}"
     state: reloaded