Apt-get ошибка обновления в Ubuntu 16.04 с использованием Ansible playbook - PullRequest
0 голосов
/ 02 апреля 2019

Я написал ANSIBLE Playbook для установки докера на Ubuntu 16.04 LTS. При запуске ANSIBLE PlayBook я получаю ошибку обновления apt-get

Я попытался запустить прикрепленный код playbook.

  - hosts: docker
    become: yes
    become_user: root
    tasks:
       - name: apt-get update
         shell: apt-get update -y
       - name: Install packages to allow apt to use a repository   overHTTPS
         shell: sudo apt-get install -y \
                apt-transport-https -y \
                ca-certificates \
                curl \
                gnupg-agent \
                software-properties-common
       - name: Add Docker’s official GPG key
         shell: curl -fsSL    https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
       - name: Use the following command to set up the stable repository
         shell: add-apt-repository \
                "deb [arch=amd64]   https://download.docker.com/linux/ubuntu\
                $(lsb_release -cs) \
                stable"
       - name: apt update
         shell: apt-get update -y
       - name: Installing the docker 17.03.0
         shell: apt-get install docker-ce=18.06.1~ce-3-0~ubuntu -y

Перед установкой докера я пытаюсь обновить сервер Ubuntu, но у меня появляется ошибка ниже

      TASK [apt update]      **************************************************************
     fatal: [localhost]: FAILED! => {"changed": true, "cmd": "apt-         get update -y", "delta": "0:00:12.338257",
     "end": "2019-04-02 11:58:13.377956", "failed": true, "rc":   100, "start": "2019-04-02 11:58:01.039699",
      "stderr": "W: The repository   'https://download.docker.com/linux/ubuntu\\ xenial Release' does not    have
      a Release file.\nE: Failed to fetch    https://download.docker.com/linux/ubuntu\\/dists/xenial/\\/binary-
     amd64/Packages  404  Not Found\nE: Some index files failed to   download. They have been ignored, or old 
     ones used instead.", "stdout": "Hit:1 http://us-  east1.gce.archive.ubuntu.com/ubuntu xenial InRelease\nH
     it:2 http://us-east1.gce.archive.ubuntu.com/ubuntu xenial- updates InRelease\nHit:3 http://us-east1.gce.
     archive.ubuntu.com/ubuntu xenial-backports InRelease\nHit:4   http://archive.canonical.com/ubuntu xenial 
     InRelease\nHit:5 http://ppa.launchpad.net/ansible/ansible/ubuntu xenial InRelease\nHit:6   http://securit
     y.ubuntu.com/ubuntu xenial-security InRelease\nIgn:7   https://download.docker.com/linux/ubuntu\\ xenial 
     InRelease\nIgn:8 https://download.docker.com/linux/ubuntu\\   xenial Release\nIgn:9 https://download.dock
    er.com/linux/ubuntu\\ xenial/\\ amd64 Packages\nIgn:10 https://download.docker.com/linux/ubuntu\\ xenia
    l/\\ all Packages\nIgn:11   https://download.docker.com/linux/ubuntu\\ xenial/\\ Translation-  en_US\nIgn:1
    2 https://download.docker.com/linux/ubuntu\\ xenial/\\   Translation-en\nIgn:13 https://download.docker.c
    om/linux/ubuntu\\ xenial/stable amd64 Packages\nIgn:14 https://download.docker.com/linux/ubuntu\\ xenia
    l/stable all Packages\nIgn:15   https://download.docker.com/linux/ubuntu\\ xenial/stable Translation-  en_U
     S\nIgn:16 https://download.docker.com/linux/ubuntu\\   xenial/stable Translation-en\nIgn:9 https://downlo
     ad.docker.com/linux/ubuntu\\ xenial/\\ amd64 Packages\nIgn:10    https://download.docker.com/linux/ubuntu\
     \ xenial/\\ all Packages\nIgn:11   https://download.docker.com/linux/ubuntu\\ xenial/\\ Translation-en_US
      \nIgn:12 https://download.docker.com/linux/ubuntu\\ xenial/\\     Translation-en\nIgn:13 https://download.d
     ocker.com/linux/ubuntu\\ xenial/stable amd64 Packages\nIgn:14   https://download.docker.com/linux/ubuntu\
     \ xenial/stable all Packages\nIgn:15     https://download.docker.com/linux/ubuntu\\ xenial/stable Translati
    on-en_US\nIgn:16 https://download.docker.com/linux/ubuntu\\    xenial/stable Translation-en\nIgn:9 https:/
    /download.docker.com/linux/ubuntu\\ xenial/\\ amd64      Packages\nIgn:10 https://download.docker.com/linux/
    ubuntu\\ xenial/\\ all Packages\nIgn:11    https://download.docker.com/linux/ubuntu\\ xenial/\\ Translatio
     n-en_US\nIgn:12 https://download.docker.com/linux/ubuntu\\  xenial/\\ Translation-en\nIgn:13 https://dow
     nload.docker.com/linux/ubuntu\\ xenial/stable amd64    Packages\nIgn:14 https://download.docker.com/linux/
   ubuntu\\ xenial/stable all Packages\nIgn:15 https://download.docker.com/linux/ubuntu\\ xenial/stable Tr
    anslation-en_US\nIgn:16 https://download.docker.com/linux/ubuntu\\ xenial/stable Translation-en\nIgn:9 
   https://download.docker.com/linux/ubuntu\\ xenial/\\ amd64 Packages\nIgn:10 https://download.docker.com
  /linux/ubuntu\\ xenial/\\ all Packages\nIgn:11  https://download.docker.com/linux/ubuntu\\ xenial/\\ Tra
  nslation-en_US\nIgn:12 https://download.docker.com/linux/ubuntu\\ xenial/\\ Translation-en\nIgn:13 http
    s://download.docker.com/linux/ubuntu\\ xenial/stable amd64  Packages\nIgn:14 https://download.docker.com
 /linux/ubuntu\\ xenial/stable all Packages\nIgn:15

1 Ответ

1 голос
/ 03 апреля 2019

В ваших командах оболочки много ошибок:

  • 2 -y в вашей команде apt-get install
  • сочетание \ и " в вашей оболочкекоманды

Но что более важно, вы должны избегать использования модуля shell, когда существует модуль, выполняющий работу, и в вашем случае вы можете использовать 3 модуля:

Что-то вроде должно работать:

- hosts: docker
  become: yes

  tasks:

    - name: Update repositories cache and install packages
      apt:
        name: apt-transport-https ca-certificates curl gnupg-agent software-properties-common
        update_cache: yes

    - name: Add Docker PGP key
      apt_key:
        url: https://download.docker.com/linux/ubuntu/gpg
        state: present

    - name: Add docker apt repository
      apt_repository:
        repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu ... stable"
        state: present

    - name: Update repositories cache and install packages
      apt:
        name: docker-ce
        update_cache: yes
...