## ---------docker daemon配置部分----------- - name: 准备docker相关目录 file: name={{ item }} state=directory with_items: - "{{ bin_dir }}" - /etc/docker - name: 下载 docker 二进制文件 copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755 with_items: - docker-containerd - docker-containerd-shim - docker-init - docker-runc - docker - docker-containerd-ctr - dockerd - docker-proxy tags: upgrade_docker, download_docker - name: docker命令自动补全 copy: src=docker dest=/etc/bash_completion.d/docker mode=0644 - name: docker国内镜像加速 template: src=daemon.json.j2 dest=/etc/docker/daemon.json - name: flush-iptables shell: "iptables -F && iptables -X \ && iptables -F -t nat && iptables -X -t nat \ && iptables -F -t raw && iptables -X -t raw \ && iptables -F -t mangle && iptables -X -t mangle" - name: 创建docker的systemd unit文件 template: src=docker.service.j2 dest=/etc/systemd/system/docker.service tags: upgrade_docker, download_docker - name: 开机启用docker 服务 shell: systemctl enable docker ignore_errors: true - name: 开启docker 服务 shell: systemctl daemon-reload && systemctl restart docker tags: upgrade_docker ## 可选 ------安装docker查询镜像 tag的小工具---- # 先要安装轻量JSON处理程序‘jq’,已在 prepare 节点安装 - name: 下载 docker-tag copy: src=docker-tag dest={{ bin_dir }}/docker-tag mode=0755