Ansible: 'docker-ce' と一致するパッケージはありません。

Ansible: 'docker-ce' と一致するパッケージはありません。

ARMバージョンのUbuntuを実行しているAmpere(arm)ベースのOracle CloudにDockerをインストールすると仮定するAnsibleプレイブックがあります。スクリプトは次のとおりです。

- name: Set sudo
  set_fact:
    ansible_become: yes
    ansible_become_method: sudo

- name: Docker installation - installing prerequisites
  ansible.builtin.apt:
    name:
      - apt-transport-https
      - ca-certificates
      - curl
      - gnupg-agent
      - software-properties-common
    update_cache: yes

- name: Docker installation - Adding apt-key
  ansible.builtin.apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg

- name: Docker installation - Adding docker repo
  ansible.builtin.apt_repository:
    repo: deb [arch=armhf] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable
    state: present
    update_cache: yes

- name: Update cache
  ansible.builtin.apt:
    update_cache: yes

- name: Docker installation - Installing Docker
  ansible.builtin.apt:
    name:
      - docker-ce
      - docker-ce-cli
      - containerd.io
    update_cache: yes

この質問をstackoverflowに投稿しましたが、ここに移動していくつかの情報を追加することをお勧めします。メッセージの1つは、 "ansible_lsb.codenameの値は何ですか? ansibleがその変数の値を印刷するように別の小さなジョブを追加しました。この部分は、問題を引き起こすtkatジョブの直前に配置されます。

- name: Print
  debug:
    msg: "{{ ansible_lsb.codename }}"

The output is the following

ok: [XXX.XXX.XXX.XXX] => {
    "msg": "mantic"
}

提案されているように、armhfビルドの可用性も確認しましたが、私が知っている限り、そのようなビルドを使用できます。

ここに画像の説明を入力してください。

問題は、何らかの理由で最後の操作「Dockerのインストール - Dockerのインストール」でエラーが発生することです。

fatal: [XXX.XXX.XXX.XXX]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}

助けてくれてありがとう。

ベストアンサー1

今日も同じ問題が発生しました!しかし、私の戦略は1年前に完璧に機能しました。有線操作...ホストに手動でリポジトリを追加しようとしましたが、すべてがうまくいきました。しかし、アンサーブルではそうではありません...

アップデート:この設定でインストールできます

- name: Install required system packages
  apt:
    name: "{{ packages }}"
    state: latest
    update_cache: yes
  vars:
    packages:
      - apt-transport-https
      - ca-certificates
      - curl
      - software-properties-common

- name: Add Docker’s official GPG key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present

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

- name: Install Docker CE
  apt:
    name: docker-ce
    state: latest
    update_cache: yes

- name: Install Docker Compose
  get_url:
    url: https://github.com/docker/compose/releases/download/1.29.2/docker-compose-{{ ansible_system }}-{{ ansible_userspace_architecture }}
    dest: /usr/local/bin/docker-compose
    mode: 'u+x,g+x'

- name: Verify Docker Compose installation
  command: docker-compose --version
  register: docker_compose_version
- debug:
    var: docker_compose_version.stdout_lines

おすすめ記事