Commit 75c799e6 authored by eric pellegrini's avatar eric pellegrini Committed by root

updated playbooks and roles with inventories variables

parent 87ed6b8a
ansible_python_interpreter: /usr/bin/python3
master_ips: "{{ groups['master'] | map('extract',hostvars,['ansible_default_ipv4','address']) | join(',') }}"
node_ips: "{{ groups['nodes'] | map('extract', hostvars, ['ansible_default_ipv4','address']) | join(',') }}"
kubernetes_admin_home: /kubernetes-admin
pod_network_cidr: 10.244.0.0/16
cni_provider: flannel
[master]
akubmaster.ill.fr
[nodes]
akubnode1.ill.fr
akubnode2.ill.fr
- hosts: nodes - hosts: k8s_nodes
remote_user: root remote_user: root
environment: environment: "{{ proxy_env }}"
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles: roles:
......
- hosts: master - hosts: k8s_masters
remote_user: root remote_user: root
environment: environment: "{{ proxy_env }}"
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles: roles:
- role: roles/initialize-control-plane - role: roles/initialize-control-plane
- role: roles/initialize-cluster - role: roles/initialize-cluster
become_user: kubernetes-admin become_user: "{{ kubernetes_admin }}"
become: yes become: yes
--- ---
- hosts: all - hosts: "{{ hostvars['novaclient']['os_groups'] }}"
remote_user: root remote_user: root
environment: "{{ proxy_env }}"
roles: roles:
- role: roles/install-docker - role: roles/install-docker
- role: roles/configure-docker - role: roles/configure-docker
- hosts: master - hosts: k8s_masters
remote_user: root remote_user: root
become_user: kubernetes-admin become_user: "{{ kubernetes_admin }}"
become: yes become: yes
environment: environment: "{{ proxy_env }}"
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles: roles:
- role: roles/install-helm - role: roles/install-helm
......
--- ---
- name: setup environment variables (noproxy ...)
import_playbook: setup_environment.yml
- name: setup docker - name: setup docker
import_playbook: setup_docker.yml import_playbook: setup_docker.yml
......
--- ---
- hosts: all - hosts: "{{ hostvars['novaclient']['os_groups'] }}"
remote_user: root remote_user: root
environment: "{{ proxy_env }}"
roles: roles:
- role: roles/install-kubernetes - role: roles/install-kubernetes
- role: roles/configure-kubernetes - role: roles/configure-kubernetes
--- ---
- hosts: - hosts: "{{ hostvars['novaclient']['os_groups'] }}"
- master
- nodes
remote_user: root remote_user: root
......
...@@ -42,3 +42,6 @@ ...@@ -42,3 +42,6 @@
name: docker name: docker
shell: /bin/bash shell: /bin/bash
state: present state: present
groups:
- sudo
...@@ -26,25 +26,34 @@ ...@@ -26,25 +26,34 @@
daemon_reload: yes daemon_reload: yes
state: restarted state: restarted
- name: create localhome directory
file:
path: /localhome
state: directory
- name: create kubernetes group - name: create kubernetes group
group: group:
name: kubernetes name: "{{ kubernetes_admin_group }}"
state: present state: present
- name: create user kubernetes-admin - name: create user kubernetes
user: user:
create_home: yes create_home: yes
home: "{{ kubernetes_admin_home }}" home: "{{ kubernetes_admin_home }}"
group: kubernetes group: "{{ kubernetes_admin_group }}"
name: kubernetes-admin name: "{{ kubernetes_admin }}"
password: "$6$d15p6Y7n2ml0Nv51$miZzKs.9f0BKeHgFj1a2qRVaR2RvRahgNiIvENylKGvTPsIYKcjRVaSthUh0JC8sAvc4PKrm4pGg.qVaxOiyo1" password: "{{ vault_kubernetes_admin_password | password_hash('sha512') }}"
shell: /bin/bash shell: /bin/bash
state: present state: present
groups:
- sudo
- name: add no_proxy to .bashrc - name: add proxy settings to /etc/environment
blockinfile: blockinfile:
path: "{{ kubernetes_admin_home }}/.bashrc" path: "/etc/environment"
block: | block: |
export no_proxy="{{ configured_no_proxy }}" {{ item.key }}={{ item.value }}
export NO_PROXY=$no_proxy marker: "# {mark} ANSIBLE MANAGED BLOCK"
loop: "{{ lookup('dict',proxy_env) }}"
--- ---
# tasks file for create-admin # tasks file for create-admin
- name: create ansible tmp directory
file:
path: "{{ kubernetes_admin_home }}/.ansible/tmp"
state: directory
- name: remove previous kubernetes configuration file - name: remove previous kubernetes configuration file
file: file:
path: "{{ kubernetes_admin_home }}/.kube" path: "{{ kubernetes_admin_home }}/.kube"
...@@ -21,8 +26,8 @@ ...@@ -21,8 +26,8 @@
- name: change ownership of ~/.kube/config - name: change ownership of ~/.kube/config
file: file:
path: "{{ kubernetes_admin_home }}/.kube/config" path: "{{ kubernetes_admin_home }}/.kube/config"
owner: kubernetes-admin owner: "{{ kubernetes_admin }}"
group: kubernetes group: "{{ kubernetes_admin_group }}"
become_user: root become_user: root
become: yes become: yes
......
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
state: absent state: absent
- name: (re)initialize the kubernetes cluster - name: (re)initialize the kubernetes cluster
command: kubeadm init --node-name={{ inventory_hostname }} --pod-network-cidr={{ pod_network_cidr }} command: kubeadm init --pod-network-cidr={{ pod_network_cidr }}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment