Commit 76d847b8 authored by eric pellegrini's avatar eric pellegrini

reorganized playbook and directories

parent 65999f7d
[defaults]
host_key_checking = false
force_handlers = True
# Use the YAML callback plugin.
stdout_callback = yaml
# Use the stdout_callback when running ad-hoc commands.
bin_ansible_callbacks = True
ansible_python_interpreter: /usr/bin/python3
master_name: "{{ hostvars[groups['master'][0]]['ansible_hostname'] }}"
master_ip: "{{ hostvars[groups['master'][0]]['ansible_default_ipv4']['address'] }}"
nodes_ip: "{{ groups['nodes'] | map('extract', hostvars, ['ansible_default_ipv4','address']) | join(',') }}"
kub_admin_home: /kub-admin
pod_network_cidr: 10.244.0.0/16
cni_provider: flannel
[master]
akubmaster.ill.fr
[nodes]
akubnode1.ill.fr
akubnode2.ill.fr
---
- hosts: all
remote_user: root
tasks:
- name: install public key
authorized_key:
user: root
state: present
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
- hosts: master
remote_user: root
tasks:
- name: install public key
authorized_key:
user: kub-admin
state: present
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
---
- hosts: all
remote_user: root
roles:
- role: roles/configure-environment
- hosts: all
remote_user: root
roles:
- role: roles/setup-docker
- role: roles/setup-kubernetes-master
- hosts: all
remote_user: root
environment:
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles:
- role: roles/cleanup-cni-interface
- hosts: master
remote_user: root
environment:
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles:
- role: roles/initialize-cluster
- role: roles/create-kubernetes-admin
- hosts: master
remote_user: kub-admin
environment:
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles:
- role: roles/setup-kubernetes-network
- hosts: nodes
remote_user: root
environment:
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles:
- role: roles/setup-kubernetes-nodes
- hosts: master
remote_user: kub-admin
environment:
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles:
- role: roles/setup-helm-package-manager
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
galaxy_info:
author: your name
description: your description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# platforms is a list of platforms, and each platform has a name and a list of versions.
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
\ No newline at end of file
---
# tasks file for cleanup-cni-interface
# see https://github.com/kubernetes/kubernetes/issues/39557
- name: reset kubernetes cluster
command: kubeadm reset --force
- name: stop docker and kubernetes services
service:
name: "{{ item }}"
state: stopped
with_items:
- kubelet
- docker
- name: remove cni and kubelet related files
file:
path: "{{ item }}"
state: absent
with_items:
- /var/lib/cni
- /var/lib/kubelet
- /etc/cni/
- name: set down network interfaces
command: "{{ item }}"
with_items:
- ifconfig cni0 down
- ifconfig {{cni_provider}}.1 down
- ifconfig docker0 down
ignore_errors: yes
- name: stop docker and kubernetes services
service:
name: "{{ item }}"
state: started
with_items:
- kubelet
- docker
---
- hosts: localhost
remote_user: root
roles:
- cleanup-cni-interface
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
---
# defaults file for configure-environment
\ No newline at end of file
---
# handlers file for configure-environment
\ No newline at end of file
galaxy_info:
author: your name
description: your description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# platforms is a list of platforms, and each platform has a name and a list of versions.
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
\ No newline at end of file
- name: generate service ips string
shell: |
printf -v service '%s,' 10.244.0.{1..253}
echo ${service%?}
args:
executable: /bin/bash
register: service_ips
- name: configure no_proxy environment variable
set_fact:
configured_no_proxy: "{{ master_ip }},{{ nodes_ip }},{{ service_ips.stdout }},{{ pod_network_cidr }},10.96.0.0/12,{{ lookup('env','no_proxy') }}"
---
# tasks file for configure-environment
- include: configure-envvar.yml
---
- hosts: localhost
remote_user: root
roles:
- configure-environment
\ No newline at end of file
---
# vars file for configure-environment
\ No newline at end of file
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
---
# defaults file for create-kubernetes-admin
\ No newline at end of file
---
# handlers file for create-kubernetes-admin
\ No newline at end of file
galaxy_info:
author: your name
description: your description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# platforms is a list of platforms, and each platform has a name and a list of versions.
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
\ No newline at end of file
- name: add kub-admin user to docker group
user:
name: kub-admin
password: $6$D2koCoNSDpEvNxAz$V6C7ZeMCUh2fai0QgvHtdJVMYoMXIzGtucVYf8a7fyTai0W.a94GKHfqIveF/ISVPtks8PlOYjQOx9yUpmZdy0
generate_ssh_key: yes
state: present
system: no
group: docker
create_home: yes
home: /kub-admin
shell: /bin/bash
groups:
- sudo
# Dirty hack for setting up no_proxy in case kub cluster is behind a proxy
# see https://medium.com/@gargankur74/setting-up-standalone-kubernetes-cluster-behind-corporate-proxy-on-ubuntu-16-04-1f2aaa5a848
- name: add no_proxy to .bashrc
blockinfile:
path: "{{ kub_admin_home }}/.bashrc"
block: |
export no_proxy="{{ configured_no_proxy }}"
export NO_PROXY=$no_proxy
---
# tasks file for create-admin
- include: create-admin.yml
---
- hosts: localhost
remote_user: root
roles:
- create-kubernetes-admin
\ No newline at end of file
---
# vars file for create-kubernetes-admin
\ No newline at end of file
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
---
# defaults file for initialize-cluster
\ No newline at end of file
---
# handlers file for initialize-cluster
\ No newline at end of file
galaxy_info:
author: your name
description: your description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)