Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

alg-1_install_docker.yaml

  • 使用一键脚本安装特别慢,下载不动,更别说多台机器,所以要提前下载好4个deb包,然后拷贝过去安装

    mkdir -p /home/ubuntu/pkg/docker
    
    curl https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.14-1_amd64.deb -o containerd.io_1.6.14-1_amd64.deb
    
    curl https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_20.10.22~3-0~ubuntu-jammy_amd64.deb -o docker-ce-cli_20.10.22~3-0~ubuntu-jammy_amd64.deb
    
    curl https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_20.10.22~3-0~ubuntu-jammy_amd64.deb -o docker-ce_20.10.22~3-0~ubuntu-jammy_amd64.deb
    
    curl https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-compose-plugin_2.14.1~ubuntu-jammy_amd64.deb -o docker-compose-plugin_2.14.1~ubuntu-jammy_amd64.deb 
    
  • 脚本内容

    - hosts: prod
      vars:
        user_path: /home/ubuntu
      tasks:
        - name: Create pkg directory
          file:
            path: "{{ user_path }}/pkg"
            recurse: yes
            state: directory
        - name: Move Docker deb
          copy:
            src: "{{ user_path }}/pkg/docker"
            dest: "{{ user_path }}/pkg"
        - name: Install Docker deb
          become: yes
          apt:
            deb: "{{ user_path }}/pkg/docker/containerd.io_1.6.14-1_amd64.deb"
        - name: Install Docker deb
          become: yes
          apt:
            deb: "{{ user_path }}/pkg/docker/docker-ce-cli_20.10.22~3-0~ubuntu-jammy_amd64.deb"
        - name: Install Docker deb
          become: yes
          apt:
            deb: "{{ user_path }}/pkg/docker/docker-ce_20.10.22~3-0~ubuntu-jammy_amd64.deb"
        - name: Install Docker deb
          become: yes
          apt:
            deb: "{{ user_path }}/pkg/docker/docker-compose-plugin_2.14.1~ubuntu-jammy_amd64.deb"
        - name: add user to docker group
          become: yes
          user:
            name: ubuntu
            groups: docker
            append: yes
        - name: reset ssh connection
          meta:
            reset_connection