ansible docker kubernetes on multiple nodes
[root@localhost ~]# cat kube.yml
- hosts: all
user: root
become: yes
become_method: sudo
become: yes
tasks:
- name: install Docker
yum:
name: docker
state: present
update_cache: true
- name: start Docker
service:
name: docker
state: started
- name: disable SELinux
command: setenforce 0
- name: disable SELinux on reboot
selinux:
state: disabled
- name: ensure net.bridge.bridge-nf-call-ip6tables is set to 1
sysctl:
name: net.bridge.bridge-nf-call-ip6tables
value: 1
state: present
- name: ensure net.bridge.bridge-nf-call-iptables is set to 1
sysctl:
name: net.bridge.bridge-nf-call-iptables
value: 1
state: present
- name: add Kubernetes' YUM repository
yum_repository:
name: Kubernetes
description: Kubernetes YUM repository
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
gpgkey: https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
gpgcheck: yes
- name: install kubelet
yum:
name: kubelet-1.14.0
state: present
update_cache: true
- name: install kubeadm
yum:
name: kubeadm-1.14.0
state: present
- name: start kubelet
service:
name: kubelet
enabled: yes
state: started
[root@localhost ~]#
[root@localhost ~]# ansible-playbook kube.yml
[WARNING]: While constructing a mapping from /root/kube.yml, line 1, column 3,
found a duplicate dict key (become). Using last defined value only.
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [192.168.0.106]
ok: [192.168.0.105]
TASK [install Docker] **********************************************************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [start Docker] ************************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [disable SELinux] *********************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [disable SELinux on reboot] ***********************************************
[WARNING]: SELinux state change will take effect next reboot
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [ensure net.bridge.bridge-nf-call-ip6tables is set to 1] ******************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [ensure net.bridge.bridge-nf-call-iptables is set to 1] *******************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [add Kubernetes' YUM repository] ******************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [install kubelet] *********************************************************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [install kubeadm] *********************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [start kubelet] ***********************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
PLAY RECAP *********************************************************************
192.168.0.105 : ok=11 changed=10 unreachable=0 failed=0
192.168.0.106 : ok=11 changed=10 unreachable=0 failed=0
[WARNING]: While constructing a mapping from /root/kube.yml, line 1, column 3,
found a duplicate dict key (become). Using last defined value only.
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [192.168.0.106]
ok: [192.168.0.105]
TASK [install Docker] **********************************************************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [start Docker] ************************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [disable SELinux] *********************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [disable SELinux on reboot] ***********************************************
[WARNING]: SELinux state change will take effect next reboot
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [ensure net.bridge.bridge-nf-call-ip6tables is set to 1] ******************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [ensure net.bridge.bridge-nf-call-iptables is set to 1] *******************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [add Kubernetes' YUM repository] ******************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [install kubelet] *********************************************************
changed: [192.168.0.105]
changed: [192.168.0.106]
TASK [install kubeadm] *********************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
TASK [start kubelet] ***********************************************************
changed: [192.168.0.106]
changed: [192.168.0.105]
PLAY RECAP *********************************************************************
192.168.0.105 : ok=11 changed=10 unreachable=0 failed=0
192.168.0.106 : ok=11 changed=10 unreachable=0 failed=0
Comments
Post a Comment