From b7696364351b5579c0d14beca0eabe61580c128d Mon Sep 17 00:00:00 2001 From: ant31 <2t.antoine@gmail.com> Date: Tue, 12 Jan 2016 17:56:29 +0100 Subject: [PATCH] Ansible 2.0 --- .travis.yml | 5 +++-- cluster.yml | 1 - roles/dnsmasq/tasks/main.yml | 8 ++------ roles/docker/tasks/main.yml | 21 ++++++++++++++++----- roles/docker/vars/centos-6.yml | 6 ------ roles/docker/vars/debian.yml | 20 ++++---------------- roles/docker/vars/fedora-20.yml | 8 +------- roles/docker/vars/redhat.yml | 8 +------- roles/kubernetes/master/tasks/main.yml | 3 +-- roles/kubernetes/master/vars/main.yml | 6 ++++++ 10 files changed, 34 insertions(+), 52 deletions(-) create mode 100644 roles/kubernetes/master/vars/main.yml diff --git a/.travis.yml b/.travis.yml index d289fb9b1..fafe46796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,14 +8,15 @@ addons: - node1 env: - - SITE=cluster.yml + - SITE=cluster.yml ANSIBLE_VERSION=2.0.0 + - SITE=cluster.yml ANSIBLE_VERSION=1.9.4 before_install: - sudo apt-get update -qq install: # Install Ansible. - - sudo -H pip install ansible + - sudo -H pip install ansible==${ANSIBLE_VERSION} - sudo -H pip install netaddr cache: diff --git a/cluster.yml b/cluster.yml index 3724554aa..d68bf8ab3 100644 --- a/cluster.yml +++ b/cluster.yml @@ -1,6 +1,5 @@ --- - hosts: downloader - sudo: no roles: - { role: download, tags: download } diff --git a/roles/dnsmasq/tasks/main.yml b/roles/dnsmasq/tasks/main.yml index 73caa4f95..df5e59a00 100644 --- a/roles/dnsmasq/tasks/main.yml +++ b/roles/dnsmasq/tasks/main.yml @@ -59,12 +59,8 @@ - name: target resolv.conf file set_fact: - resolvconffile: > - {%- if resolvconf.stat.exists == True -%} - /etc/resolvconf/resolv.conf.d/head - {%- else -%} - /etc/resolv.conf - {%- endif -%} + resolvconffile: >- + {%- if resolvconf.stat.exists == True -%}/etc/resolvconf/resolv.conf.d/head{%- else -%}/etc/resolv.conf{%- endif -%} - name: Add search resolv.conf lineinfile: diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 4f95be0db..bf268cf93 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -22,25 +22,36 @@ - name: ensure docker requirements packages are installed action: "{{ docker_package_info.pkg_mgr }}" - args: docker_package_info.args + args: + name: "{{item}}" + state: latest + update_cache: yes with_items: docker_package_info.pre_pkgs when: docker_package_info.pre_pkgs|length > 0 - name: ensure docker repository public key is installed action: "{{ docker_repo_key_info.pkg_key }}" - args: docker_repo_key_info.args + args: + id: "{{item}}" + keyserver: "{{docker_repo_key_info.keyserver}}" + state: present with_items: docker_repo_key_info.repo_keys - when: docker_repo_key_info.repo_keys|length > 0 - name: ensure docker repository is enabled action: "{{ docker_repo_info.pkg_repo }}" - args: docker_repo_info.args + args: + repo: "{{item}}" + update_cache: yes + state: present with_items: docker_repo_info.repos when: docker_repo_info.repos|length > 0 - name: ensure docker packages are installed action: "{{ docker_package_info.pkg_mgr }}" - args: docker_package_info.args + args: + pkg: "{{item}}" + update_cache: yes + state: latest with_items: docker_package_info.pkgs when: docker_package_info.pkgs|length > 0 diff --git a/roles/docker/vars/centos-6.yml b/roles/docker/vars/centos-6.yml index e6937d595..a95320f44 100644 --- a/roles/docker/vars/centos-6.yml +++ b/roles/docker/vars/centos-6.yml @@ -2,10 +2,6 @@ docker_kernel_min_version: '2.6.32-431' docker_package_info: pkg_mgr: yum - args: - name: "{{ item }}" - state: latest - update_cache: yes pre_pkgs: - epel-release - curl @@ -15,10 +11,8 @@ docker_package_info: docker_repo_key_info: pkg_key: '' - args: {} repo_keys: [] docker_repo_info: pkg_repo: '' - args: {} repos: [] diff --git a/roles/docker/vars/debian.yml b/roles/docker/vars/debian.yml index 37cf3e021..6140f47d3 100644 --- a/roles/docker/vars/debian.yml +++ b/roles/docker/vars/debian.yml @@ -2,12 +2,7 @@ docker_kernel_min_version: '3.2' docker_package_info: pkg_mgr: apt - args: - pkg: "{{ item }}" - update_cache: yes - cache_valid_time: 600 - state: latest - pre_pkgs: + pre_pkgs: - apt-transport-https - curl - software-properties-common @@ -16,21 +11,14 @@ docker_package_info: docker_repo_key_info: pkg_key: apt_key - args: - id: "{{ item }}" - keyserver: hkp://p80.pool.sks-keyservers.net:80 - state: present + keyserver: hkp://p80.pool.sks-keyservers.net:80 repo_keys: - - 58118E89F3A912897C070ADBF76221572C52609D + - 58118E89F3A912897C070ADBF76221572C52609D docker_repo_info: pkg_repo: apt_repository - args: - repo: "{{ item }}" - update_cache: yes - state: present repos: - > - deb https://apt.dockerproject.org/repo + deb https://apt.dockerproject.org/repo {{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }} main diff --git a/roles/docker/vars/fedora-20.yml b/roles/docker/vars/fedora-20.yml index 94e51ce27..1c89e4b95 100644 --- a/roles/docker/vars/fedora-20.yml +++ b/roles/docker/vars/fedora-20.yml @@ -2,21 +2,15 @@ docker_kernel_min_version: '0' docker_package_info: pkg_mgr: yum - args: - name: "{{ item }}" - state: latest - update_cache: yes - pre_pkgs: + pre_pkgs: - curl pkgs: - docker-io docker_repo_key_info: pkg_key: '' - args: {} repo_keys: [] docker_repo_info: pkg_repo: '' - args: {} repos: [] diff --git a/roles/docker/vars/redhat.yml b/roles/docker/vars/redhat.yml index 6c251ccec..9d0dd2c49 100644 --- a/roles/docker/vars/redhat.yml +++ b/roles/docker/vars/redhat.yml @@ -2,21 +2,15 @@ docker_kernel_min_version: '0' docker_package_info: pkg_mgr: yum - args: - name: "{{ item }}" - state: latest - update_cache: yes - pre_pkgs: + pre_pkgs: - curl pkgs: - docker docker_repo_key_info: pkg_key: '' - args: {} repo_keys: [] docker_repo_info: pkg_repo: '' - args: {} repos: [] diff --git a/roles/kubernetes/master/tasks/main.yml b/roles/kubernetes/master/tasks/main.yml index 728c6bb19..cbdf555e7 100644 --- a/roles/kubernetes/master/tasks/main.yml +++ b/roles/kubernetes/master/tasks/main.yml @@ -60,9 +60,8 @@ uri: url: http://127.0.0.1:{{ kube_apiserver_insecure_port }}/api/v1/namespaces method: POST - body: '{"apiVersion":"v1","kind":"Namespace","metadata":{"name":"kube-system"}}' + body: "{{namespace_kubesystem|to_json}}" status_code: 201,409 - body_format: json run_once: yes when: inventory_hostname == groups['kube-master'][0] diff --git a/roles/kubernetes/master/vars/main.yml b/roles/kubernetes/master/vars/main.yml new file mode 100644 index 000000000..2eeb525fe --- /dev/null +++ b/roles/kubernetes/master/vars/main.yml @@ -0,0 +1,6 @@ +--- +namespace_kubesystem: + apiVersion: v1 + kind: Namespace + metadata: + name: kube-system \ No newline at end of file