# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: master vars: kubeadm_aio_action: join-kube kubeadm_aio_join_command: null block: - name: "deploying kubeadm {{ kubeadm_aio_action }} container" become: true become_user: root docker_container: name: "kubeadm-{{ kubeadm_aio_action }}" image: "{{ images.kubernetes.kubeadm_aio }}" state: started detach: false recreate: yes pid_mode: host network_mode: host capabilities: SYS_ADMIN volumes: - /sys:/sys:rw - /run:/run:rw - /:/mnt/rootfs:rw - /etc:/etc:rw env: CONTAINER_NAME="kubeadm-{{ kubeadm_aio_action }}" ACTION="{{ kubeadm_aio_action }}" KUBEADM_JOIN_COMMAND="{{ kubeadm_aio_join_command }}" register: kubeadm_aio_join_container rescue: - name: "getting logs for {{ kubeadm_aio_action }} action" command: "docker logs kubeadm-{{ kubeadm_aio_action }}" become: true become_user: root register: kubeadm_aio_join_container_output - name: "dumping logs for {{ kubeadm_aio_action }} action" debug: msg: "{{ kubeadm_aio_join_container_output.stdout_lines }}" - name: "exiting if {{ kubeadm_aio_action }} action failed" command: exit 1 always: - name: "removing container for {{ kubeadm_aio_action }} action" become: true become_user: root docker_container: name: "kubeadm-{{ kubeadm_aio_action }}" state: absent ...