---
# Install Flannel.

- name: Force to use github-release when packages are not available
  set_fact:
    flannel_source_type: "github-release"
  when: is_coreos or ansible_distribution == "Ubuntu"

- name: Install Flannel with package manager
  action: "{{ ansible_pkg_mgr }}"
  args:
        name: flannel
        state: latest
  when: not is_atomic and flannel_source_type != "github-release"

- set_fact:
    flannel_use_upstart: "{{ ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 15 }}"

- name: Install Flannel with github release
  include: github-release.yml
  when: flannel_source_type == "github-release"

- name: Set Flannel config file directory
  set_fact:
    flannel_config_dir: "/etc/sysconfig"

- name: Override Flannel config file directory for Ubuntu
  set_fact:
    flannel_config_dir: "/etc/flannel"
  when: flannel_use_upstart

- name: Create config file directory
  file: path={{ flannel_config_dir }} state=directory

- name: Install Flannel config file
  template: src=flanneld.j2 dest={{ flannel_config_dir }}/flanneld
  notify:
    - restart flannel

---
# Install Flannel.

- name: Force to use github-release when packages are not available
  set_fact:
    flannel_source_type: "github-release"
  when: is_coreos or ansible_distribution == "Ubuntu"

- name: Install Flannel with package manager
  action: "{{ ansible_pkg_mgr }}"
  args:
        name: flannel
        state: latest
  when: not is_atomic and flannel_source_type != "github-release"

- set_fact: 
    flannel_use_upstart: false

- set_fact:
    flannel_use_upstart: true
  when:  "{{ ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 15 }}"

- name: Install Flannel with github release
  include: github-release.yml
  when: flannel_source_type == "github-release"

- name: Set Flannel config file directory
  set_fact:
    flannel_config_dir: "/etc/sysconfig"

- name: Override Flannel config file directory for Ubuntu
  set_fact:
    flannel_config_dir: "/etc/flannel"
  when: flannel_use_upstart

- name: Create config file directory
  file: path={{ flannel_config_dir }} state=directory

- name: Install Flannel config file
  template: src=flanneld.j2 dest={{ flannel_config_dir }}/flanneld
  notify:
    - restart flannel

Fix for setting the upstart fact for ansible prior to 2.0.2[D
Fix for setting the upstart fact for ansible prior to 2.0.2[D
