mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-03-27 05:45:05 -02:30
common role in order to support other linux distribs
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
---
|
||||
- name: Create calico release directory
|
||||
local_action: file
|
||||
path={{ local_release_dir }}/calico/bin
|
||||
recurse=yes
|
||||
state=directory
|
||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||
|
||||
- name: Check if calicoctl has been downloaded
|
||||
local_action: stat
|
||||
path={{ local_release_dir }}/calico/bin/calicoctl
|
||||
register: c_tar
|
||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||
|
||||
# issues with get_url module and redirects, to be tested again in the near future
|
||||
- name: Download calico
|
||||
local_action: shell
|
||||
curl -o {{ local_release_dir }}/calico/bin/calicoctl -Ls {{ calico_download_url }}/{{ calico_version }}/calicoctl
|
||||
when: not c_tar.stat.exists
|
||||
register: dl_calico
|
||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||
|
||||
|
||||
- name: Download calico-kubernetes-plugin
|
||||
local_action: get_url
|
||||
url="{{calico_plugin_download_url}}"
|
||||
dest="{{ local_release_dir }}/calico/bin/calico"
|
||||
@@ -1,4 +1,31 @@
|
||||
---
|
||||
- name: Create calico release directory
|
||||
local_action: file
|
||||
path={{ local_release_dir }}/calico/bin
|
||||
recurse=yes
|
||||
state=directory
|
||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||
|
||||
- name: Check if calicoctl has been downloaded
|
||||
local_action: stat
|
||||
path={{ local_release_dir }}/calico/bin/calicoctl
|
||||
register: c_tar
|
||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||
|
||||
# issues with get_url module and redirects, to be tested again in the near future
|
||||
- name: Download calico
|
||||
local_action: shell
|
||||
curl -o {{ local_release_dir }}/calico/bin/calicoctl -Ls {{ calico_download_url }}/{{ calico_version }}/calicoctl
|
||||
when: not c_tar.stat.exists
|
||||
register: dl_calico
|
||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||
|
||||
|
||||
- name: Download calico-kubernetes-plugin
|
||||
local_action: get_url
|
||||
url="{{calico_plugin_download_url}}"
|
||||
dest="{{ local_release_dir }}/calico/bin/calico"
|
||||
|
||||
- name: Create flannel release directory
|
||||
local_action: file
|
||||
path={{ local_release_dir }}/flannel
|
||||
@@ -37,3 +64,20 @@
|
||||
local_action: file
|
||||
path={{ local_release_dir }}/flannel/flannel-{{ flannel_version }} state=absent
|
||||
when: dl_flannel|changed
|
||||
|
||||
- name: Create kubernetes binary directory
|
||||
local_action: file
|
||||
path="{{ local_release_dir }}/kubernetes/bin"
|
||||
state=directory
|
||||
recurse=yes
|
||||
|
||||
- name: Download kubelet and kubectl
|
||||
local_action: get_url
|
||||
url="{{ kube_download_url }}/{{ item.name }}"
|
||||
dest="{{ local_release_dir }}/kubernetes/bin"
|
||||
sha256sum="{{ item.checksum }}"
|
||||
with_items:
|
||||
- name: kubelet
|
||||
checksum: "{{ kubelet_checksum }}"
|
||||
- name: kubectl
|
||||
checksum: "{{ kubectl_checksum }}"
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
- name: Create kubernetes binary directory
|
||||
local_action: file
|
||||
path="{{ local_release_dir }}/kubernetes/bin"
|
||||
state=directory
|
||||
recurse=yes
|
||||
|
||||
- name: Download kubelet and kubectl
|
||||
local_action: get_url
|
||||
url="{{ kube_download_url }}/{{ item.name }}"
|
||||
dest="{{ local_release_dir }}/kubernetes/bin"
|
||||
sha256sum="{{ item.checksum }}"
|
||||
with_items:
|
||||
- name: kubelet
|
||||
checksum: "{{ kubelet_checksum }}"
|
||||
- name: kubectl
|
||||
checksum: "{{ kubectl_checksum }}"
|
||||
@@ -3,10 +3,24 @@
|
||||
delegate_to: localhost
|
||||
when: inventory_hostname == "{{ groups['kube-master'][0] }}"
|
||||
|
||||
- include: pip-bootstrap.yml
|
||||
- name: "Identify init system"
|
||||
shell: >
|
||||
if $(pgrep systemd > /dev/null); then
|
||||
echo systemd;
|
||||
else echo sysvinit;
|
||||
fi
|
||||
always_run: True
|
||||
register: init_system_output
|
||||
|
||||
- name: Install httplib2 python module
|
||||
pip:
|
||||
executable: "{{ ansible_user_dir }}/bin/pip"
|
||||
- set_fact:
|
||||
init_system: "{{ init_system_output.stdout }}"
|
||||
|
||||
- name: Install debian packages requirements
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
with_items: pip_python_modules
|
||||
state: latest
|
||||
when: ansible_os_family == "Debian"
|
||||
with_items: req_debian_pkg
|
||||
|
||||
- include: python-bootstrap.yml
|
||||
when: ansible_os_family not in [ "Debian", "RedHat" ]
|
||||
|
||||
41
roles/common/tasks/python-bootstrap.yml
Normal file
41
roles/common/tasks/python-bootstrap.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
- name: Python | Check if bootstrap is needed
|
||||
raw: stat {{ bin_dir}}/.bootstrapped
|
||||
register: need_bootstrap
|
||||
ignore_errors: True
|
||||
|
||||
- name: Python | Run bootstrap.sh
|
||||
script: bootstrap.sh
|
||||
when: need_bootstrap | failed
|
||||
|
||||
- set_fact:
|
||||
ansible_python_interpreter: "{{ bin_dir }}/python"
|
||||
|
||||
- name: Python | Check if we need to install pip
|
||||
shell: "{{ansible_python_interpreter}} -m pip --version"
|
||||
register: need_pip
|
||||
ignore_errors: True
|
||||
changed_when: false
|
||||
when: need_bootstrap | failed
|
||||
|
||||
- name: Python | Copy get-pip.py
|
||||
copy: src=get-pip.py dest=~/get-pip.py
|
||||
when: need_pip | failed
|
||||
|
||||
- name: Python | Install pip
|
||||
shell: "{{ansible_python_interpreter}} ~/get-pip.py"
|
||||
when: need_pip | failed
|
||||
|
||||
- name: Python | Remove get-pip.py
|
||||
file: path=~/get-pip.py state=absent
|
||||
when: need_pip | failed
|
||||
|
||||
- name: Python | Install pip launcher
|
||||
copy: src=runner dest={{ bin_dir }}/pip mode=0755
|
||||
when: need_pip | failed
|
||||
|
||||
- name: Install required python modules
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
with_items: pip_python_modules
|
||||
|
||||
Reference in New Issue
Block a user