Better fix for different CoreOS os family facts

Signed-off-by: Bogdan Dobrelya <bogdando@mail.ru>
This commit is contained in:
Bogdan Dobrelya 2017-01-05 16:32:08 +01:00
parent c0400e9db5
commit 5af2c42bde
17 changed files with 35 additions and 35 deletions

View file

@ -15,7 +15,7 @@
service: service:
name: docker.socket name: docker.socket
state: restarted state: restarted
when: ansible_os_family == 'Container Linux by CoreOS' when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
- name: Docker | reload docker - name: Docker | reload docker
service: service:

View file

@ -20,7 +20,7 @@
docker requires a minimum kernel version of docker requires a minimum kernel version of
{{ docker_kernel_min_version }} on {{ docker_kernel_min_version }} on
{{ ansible_distribution }}-{{ ansible_distribution_version }} {{ ansible_distribution }}-{{ ansible_distribution_version }}
when: (ansible_os_family != "Container Linux by CoreOS") and (ansible_kernel|version_compare(docker_kernel_min_version, "<")) when: (not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]) and (ansible_kernel|version_compare(docker_kernel_min_version, "<"))
tags: facts tags: facts
- name: ensure docker repository public key is installed - name: ensure docker repository public key is installed
@ -34,7 +34,7 @@
retries: 4 retries: 4
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ docker_repo_key_info.repo_keys }}" with_items: "{{ docker_repo_key_info.repo_keys }}"
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: ensure docker repository is enabled - name: ensure docker repository is enabled
action: "{{ docker_repo_info.pkg_repo }}" action: "{{ docker_repo_info.pkg_repo }}"
@ -42,7 +42,7 @@
repo: "{{item}}" repo: "{{item}}"
state: present state: present
with_items: "{{ docker_repo_info.repos }}" with_items: "{{ docker_repo_info.repos }}"
when: (ansible_os_family != "Container Linux by CoreOS") and (docker_repo_info.repos|length > 0) when: (not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]) and (docker_repo_info.repos|length > 0)
- name: Configure docker repository on RedHat/CentOS - name: Configure docker repository on RedHat/CentOS
copy: copy:
@ -61,7 +61,7 @@
retries: 4 retries: 4
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ docker_package_info.pkgs }}" with_items: "{{ docker_package_info.pkgs }}"
when: (ansible_os_family != "Container Linux by CoreOS") and (docker_package_info.pkgs|length > 0) when: (not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]) and (docker_package_info.pkgs|length > 0)
- name: Set docker systemd config - name: Set docker systemd config
include: systemd.yml include: systemd.yml

View file

@ -13,7 +13,7 @@
src: docker.service.j2 src: docker.service.j2
dest: /etc/systemd/system/docker.service dest: /etc/systemd/system/docker.service
register: docker_service_file register: docker_service_file
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Write docker options systemd drop-in - name: Write docker options systemd drop-in
template: template:

View file

@ -119,7 +119,7 @@
delegate_to: "{{ download_delegate }}" delegate_to: "{{ download_delegate }}"
register: saved register: saved
run_once: true run_once: true
when: (ansible_os_family != "Container Linux by CoreOS" or download_delegate == "localhost") and download_run_once|bool and download.enabled|bool and download.container|bool and (container_changed|bool or not img.stat.exists) when: (not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or download_delegate == "localhost") and download_run_once|bool and download.enabled|bool and download.container|bool and (container_changed|bool or not img.stat.exists)
- name: Download | copy container images to ansible host - name: Download | copy container images to ansible host
synchronize: synchronize:
@ -128,7 +128,7 @@
mode: pull mode: pull
delegate_to: localhost delegate_to: localhost
become: false become: false
when: ansible_os_family != "Container Linux by CoreOS" and inventory_hostname == groups['kube-master'][0] and download_delegate != "localhost" and download_run_once|bool and download.enabled|bool and download.container|bool and saved.changed when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] and inventory_hostname == groups['kube-master'][0] and download_delegate != "localhost" and download_run_once|bool and download.enabled|bool and download.container|bool and saved.changed
- name: Download | upload container images to nodes - name: Download | upload container images to nodes
synchronize: synchronize:
@ -141,10 +141,10 @@
until: get_task|success until: get_task|success
retries: 4 retries: 4
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
when: (ansible_os_family != "Container Linux by CoreOS" and inventory_hostname != groups['kube-master'][0] or download_delegate == "localhost") and download_run_once|bool and download.enabled|bool and download.container|bool when: (not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] and inventory_hostname != groups['kube-master'][0] or download_delegate == "localhost") and download_run_once|bool and download.enabled|bool and download.container|bool
tags: [upload, upgrade] tags: [upload, upgrade]
- name: Download | load container images - name: Download | load container images
shell: "{{ docker_bin_dir }}/docker load < {{ fname }}" shell: "{{ docker_bin_dir }}/docker load < {{ fname }}"
when: (ansible_os_family != "Container Linux by CoreOS" and inventory_hostname != groups['kube-master'][0] or download_delegate == "localhost") and download_run_once|bool and download.enabled|bool and download.container|bool when: (not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] and inventory_hostname != groups['kube-master'][0] or download_delegate == "localhost") and download_run_once|bool and download.enabled|bool and download.container|bool
tags: [upload, upgrade] tags: [upload, upgrade]

View file

@ -2,7 +2,7 @@
dependencies: dependencies:
- role: adduser - role: adduser
user: "{{ addusers.etcd }}" user: "{{ addusers.etcd }}"
when: ansible_os_family != 'Container Linux by CoreOS' when: not ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
- role: download - role: download
file: "{{ downloads.etcd }}" file: "{{ downloads.etcd }}"
tags: download tags: download

View file

@ -129,7 +129,7 @@
/usr/local/share/ca-certificates/etcd-ca.crt /usr/local/share/ca-certificates/etcd-ca.crt
{%- elif ansible_os_family == "RedHat" -%} {%- elif ansible_os_family == "RedHat" -%}
/etc/pki/ca-trust/source/anchors/etcd-ca.crt /etc/pki/ca-trust/source/anchors/etcd-ca.crt
{%- elif ansible_os_family == "Container Linux by CoreOS" -%} {%- elif ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] -%}
/etc/ssl/certs/etcd-ca.pem /etc/ssl/certs/etcd-ca.pem
{%- endif %} {%- endif %}
tags: facts tags: facts

View file

@ -3,7 +3,7 @@
notify: notify:
- Preinstall | reload network - Preinstall | reload network
- Preinstall | reload kubelet - Preinstall | reload kubelet
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
# FIXME(bogdando) https://github.com/projectcalico/felix/issues/1185 # FIXME(bogdando) https://github.com/projectcalico/felix/issues/1185
- name: Preinstall | reload network - name: Preinstall | reload network
@ -15,18 +15,18 @@
networking networking
{%- endif %} {%- endif %}
state: restarted state: restarted
when: ansible_os_family != "Container Linux by CoreOS" and kube_network_plugin not in ['canal', 'calico'] when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] and kube_network_plugin not in ['canal', 'calico']
- name: Preinstall | update resolvconf for Container Linux by CoreOS - name: Preinstall | update resolvconf for Container Linux by CoreOS
command: /bin/true command: /bin/true
notify: notify:
- Preinstall | apply resolvconf cloud-init - Preinstall | apply resolvconf cloud-init
- Preinstall | reload kubelet - Preinstall | reload kubelet
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Preinstall | apply resolvconf cloud-init - name: Preinstall | apply resolvconf cloud-init
command: /usr/bin/coreos-cloudinit --from-file {{ resolveconf_cloud_init_conf }} command: /usr/bin/coreos-cloudinit --from-file {{ resolveconf_cloud_init_conf }}
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Preinstall | reload kubelet - name: Preinstall | reload kubelet
service: service:

View file

@ -5,7 +5,7 @@
- name: Force binaries directory for Container Linux by CoreOS - name: Force binaries directory for Container Linux by CoreOS
set_fact: set_fact:
bin_dir: "/opt/bin" bin_dir: "/opt/bin"
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: facts tags: facts
- name: check bin dir exists - name: check bin dir exists
@ -131,7 +131,7 @@
retries: 4 retries: 4
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}" with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: bootstrap-os tags: bootstrap-os
- name: Disable IPv6 DNS lookup - name: Disable IPv6 DNS lookup
@ -140,7 +140,7 @@
line: "precedence ::ffff:0:0/96 100" line: "precedence ::ffff:0:0/96 100"
state: present state: present
backup: yes backup: yes
when: disable_ipv6_dns and ansible_os_family != "Container Linux by CoreOS" when: disable_ipv6_dns and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: bootstrap-os tags: bootstrap-os
# Todo : selinux configuration # Todo : selinux configuration

View file

@ -1,7 +1,7 @@
--- ---
- name: create temporary resolveconf cloud init file - name: create temporary resolveconf cloud init file
command: cp -f /etc/resolv.conf "{{ resolvconffile }}" command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Remove search/domain/nameserver options - name: Remove search/domain/nameserver options
lineinfile: lineinfile:
@ -48,7 +48,7 @@
- name: get temporary resolveconf cloud init file content - name: get temporary resolveconf cloud init file content
command: cat {{ resolvconffile }} command: cat {{ resolvconffile }}
register: cloud_config register: cloud_config
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: persist resolvconf cloud init file - name: persist resolvconf cloud init file
template: template:
@ -57,8 +57,8 @@
owner: root owner: root
mode: 0644 mode: 0644
notify: Preinstall | update resolvconf for Container Linux by CoreOS notify: Preinstall | update resolvconf for Container Linux by CoreOS
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- include: dhclient-hooks.yml - include: dhclient-hooks.yml
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: [bootstrap-os, resolvconf] tags: [bootstrap-os, resolvconf]

View file

@ -35,11 +35,11 @@
{%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/base{%- endif -%} {%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/base{%- endif -%}
head: >- head: >-
{%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/head{%- endif -%} {%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/head{%- endif -%}
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: target temporary resolvconf cloud init file (Container Linux by CoreOS) - name: target temporary resolvconf cloud init file (Container Linux by CoreOS)
set_fact: resolvconffile=/tmp/resolveconf_cloud_init_conf set_fact: resolvconffile=/tmp/resolveconf_cloud_init_conf
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: target dhclient conf/hook files for Red Hat family - name: target dhclient conf/hook files for Red Hat family
set_fact: set_fact:

View file

@ -74,7 +74,7 @@
/usr/local/share/ca-certificates/kube-ca.crt /usr/local/share/ca-certificates/kube-ca.crt
{%- elif ansible_os_family == "RedHat" -%} {%- elif ansible_os_family == "RedHat" -%}
/etc/pki/ca-trust/source/anchors/kube-ca.crt /etc/pki/ca-trust/source/anchors/kube-ca.crt
{%- elif ansible_os_family == "Container Linux by CoreOS" -%} {%- elif ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] -%}
/etc/ssl/certs/kube-ca.pem /etc/ssl/certs/kube-ca.pem
{%- endif %} {%- endif %}
tags: facts tags: facts

View file

@ -1,6 +1,6 @@
dependencies: dependencies:
- role: etcd - role: etcd
- role: docker - role: docker
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- role: download - role: download
file: "{{ downloads.calico_rr }}" file: "{{ downloads.calico_rr }}"

View file

@ -20,7 +20,7 @@
service: service:
name: docker.socket name: docker.socket
state: restarted state: restarted
when: ansible_os_family == 'Container Linux by CoreOS' when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
- name: Flannel | reload docker - name: Flannel | reload docker
service: service:

View file

@ -1,5 +1,5 @@
[Service] [Service]
{% if ansible_os_family == "Container Linux by CoreOS" %} {% if ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] %}
Environment="DOCKER_OPT_BIP=--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}" Environment="DOCKER_OPT_BIP=--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"
{% else %} {% else %}
Environment="DOCKER_NETWORK_OPTIONS=--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}" Environment="DOCKER_NETWORK_OPTIONS=--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"

View file

@ -10,11 +10,11 @@
- name: Force binaries directory for Container Linux by CoreOS - name: Force binaries directory for Container Linux by CoreOS
set_fact: set_fact:
bin_dir: "/opt/bin" bin_dir: "/opt/bin"
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- set_fact: - set_fact:
bin_dir: "/usr/local/bin" bin_dir: "/usr/local/bin"
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Run a replica controller composed of 2 pods - name: Run a replica controller composed of 2 pods
shell: "{{bin_dir}}/kubectl run test --image={{test_image_repo}}:{{test_image_tag}} --replicas=2 --command -- tail -f /dev/null" shell: "{{bin_dir}}/kubectl run test --image={{test_image_repo}}:{{test_image_tag}} --replicas=2 --command -- tail -f /dev/null"

View file

@ -6,11 +6,11 @@
- name: Force binaries directory for Container Linux by CoreOS - name: Force binaries directory for Container Linux by CoreOS
set_fact: set_fact:
bin_dir: "/opt/bin" bin_dir: "/opt/bin"
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- set_fact: - set_fact:
bin_dir: "/usr/local/bin" bin_dir: "/usr/local/bin"
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Get pod names - name: Get pod names
shell: "{{bin_dir}}/kubectl get pods -o json" shell: "{{bin_dir}}/kubectl get pods -o json"

View file

@ -15,11 +15,11 @@
- name: Force binaries directory for Container Linux by CoreOS - name: Force binaries directory for Container Linux by CoreOS
set_fact: set_fact:
bin_dir: "/opt/bin" bin_dir: "/opt/bin"
when: ansible_os_family == "Container Linux by CoreOS" when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- set_fact: - set_fact:
bin_dir: "/usr/local/bin" bin_dir: "/usr/local/bin"
when: ansible_os_family != "Container Linux by CoreOS" when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Wait for netchecker server - name: Wait for netchecker server
shell: "{{ bin_dir }}/kubectl get pods --namespace {{netcheck_namespace}} | grep ^netchecker-server" shell: "{{ bin_dir }}/kubectl get pods --namespace {{netcheck_namespace}} | grep ^netchecker-server"