# 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: generate the kubeadm join command for nodes vars: kubeadm_aio_action: generate-join-cmd kubeadm_cluster_join_ttl: 30m kube_worker: null block: - name: "deploying kubeadm {{ kubeadm_aio_action }} container" become: true become_user: root docker_container: name: "kubeadm-{{ kube_worker }}-{{ kubeadm_aio_action }}" image: "{{ images.kubernetes.kubeadm_aio }}" state: started detach: false recreate: yes network_mode: host volumes: - /etc/kubernetes:/etc/kubernetes:ro env: ACTION=generate-join-cmd TTL="{{ kubeadm_cluster_join_ttl }}" register: kubeadm_generate_join_command - name: "getting logs for {{ kubeadm_aio_action }} action" command: "docker logs kubeadm-{{ kube_worker }}-{{ kubeadm_aio_action }}" become: true become_user: root register: kubeadm_aio_action_logs - name: storing cluster join command set_fact: kubeadm_cluster_join_command="{{ kubeadm_aio_action_logs.stdout | regex_search('kubeadm join.*') }}" rescue: - name: "dumping logs for {{ kubeadm_aio_action }} action" debug: var: kubeadm_aio_action_logs.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-{{ kube_worker }}-{{ kubeadm_aio_action }}" state: absent ...