Skip to content
Snippets Groups Projects
main.yml 2.97 KiB
Newer Older
  • Learn to ignore specific revisions
  • - include: gitinfos.yml
    
      when: run_gitinfos
    
    Smaine Kahlouch's avatar
    Smaine Kahlouch committed
    - name: gather os specific variables
      include_vars: "{{ item }}"
      with_first_found:
        - files:
          - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
          - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
          - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
          - "{{ ansible_distribution|lower }}.yml"
          - "{{ ansible_os_family|lower }}.yml"
          - defaults.yml
          paths:
          - ../vars
    
    Smana's avatar
    Smana committed
          skip: true
    
    - name: Force binaries directory for CoreOS
      set_fact:
        bin_dir: "/opt/bin"
      when: ansible_os_family == "CoreOS"
    
    - name: Create kubernetes config directory
      file:
        path: "{{ kube_config_dir }}"
        state: directory
        owner: kube
    
    - name: Create kubernetes script directory
      file:
        path: "{{ kube_script_dir }}"
        state: directory
        owner: kube
    
    - name: Create kubernetes manifests directory
      file:
        path: "{{ kube_manifest_dir }}"
        state: directory
        owner: kube
    
    - name: Create kubernetes logs directory
      file:
        path: "{{ kube_log_dir }}"
        state: directory
        owner: kube
    
      when: ansible_service_mgr in ["sysvinit","upstart"]
    
    - name: check cloud_provider value
      fail:
        msg: "If set the 'cloud_provider' var must be set eithe to 'gce' or 'aws'"
      when: cloud_provider is defined and cloud_provider not in ['gce', 'aws']
    
    
    - name: Create cni directories
      file:
        path: "{{ item }}"
        state: directory
        owner: kube
      with_items:
        - "/etc/cni/net.d"
        - "/opt/cni/bin"
      when: kube_network_plugin == "calico"
    
    
    - name: Update package management cache (APT)
      apt: update_cache=yes
      when: ansible_pkg_mgr == 'apt'
    
    - name: Update package management cache (YUM)
      yum: update_cache=yes name='*'
      when: ansible_pkg_mgr == 'yum'
    
    Smaine Kahlouch's avatar
    Smaine Kahlouch committed
    - name: Install python-apt for Debian distribs
    
    Smana's avatar
    Smana committed
      command: apt-get install -y python-apt
    
      when: ansible_os_family == "Debian"
    
    Smaine Kahlouch's avatar
    Smaine Kahlouch committed
      changed_when: False
    
    - name: Install python-dnf for latest RedHat versions
    
    Smana's avatar
    Smana committed
      command: dnf install -y python-dnf yum
    
    Smaine Kahlouch's avatar
    Smaine Kahlouch committed
      when: ansible_distribution == "Fedora" and
            ansible_distribution_major_version > 21
      changed_when: False
    
    Smana's avatar
    Smana committed
    - name: Install epel-release on RHEL
      command: rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
      when: ansible_distribution == "RedHat"
    
    - name: Install epel-release on CentOS
    
      action:
        module: "{{ ansible_pkg_mgr }}"
        name: "epel-release"
        state: latest
    
    Smana's avatar
    Smana committed
      when: ansible_distribution == "CentOS"
    
    Smaine Kahlouch's avatar
    Smaine Kahlouch committed
    - name: Install packages requirements
    
      action:
        module: "{{ ansible_pkg_mgr }}"
        name: "{{ item }}"
        state: latest
    
    Smana's avatar
    Smana committed
      with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
      when: ansible_os_family != "CoreOS"
    
    Smaine Kahlouch's avatar
    Smaine Kahlouch committed
    
    # Todo : selinux configuration
    - name: Set selinux policy to permissive
      selinux: policy=targeted state=permissive
    
      when: ansible_os_family == "RedHat"
    
    Smaine Kahlouch's avatar
    Smaine Kahlouch committed
      changed_when: False
    
    - include: etchosts.yml