Juliatzin
Juliatzin

Reputation: 19695

Can't pull a docker image using ansible and community.general.docker_image

In a ansible playbook, I'm trying to pull an image, and retag it:

docker pull hyperledger/fabric-ccenv:amd64-1.4.4
docker tag hyperledger/fabric-ccenv:amd64-1.4.4 hyperledger/fabric-ccenv:latest

I can't even succeed to pull it.

I do it with community.general.docker_image:

ansible-galaxy collection install community.general

and then my playbook:

---
- name: Pull an image
  hosts: nodes
  become: true
  community.general.docker_image:
    name: hyperledger/fabric-ccenv:amd64-1.4.4
    source: pull

And running with :

ansible-playbook install-dependencies.yml

I get this error:

ERROR! 'community.general.docker_image' is not a valid attribute for a Play

The error appears to be in 'install-dependencies.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: Pull an image
  ^ here

What am I doing wrong ?

Upvotes: 4

Views: 2614

Answers (1)

sadok-f
sadok-f

Reputation: 1447

You're missing the tasks option in your playbook:


- name: Pull an image
  hosts: nodes
  become: true
  tasks:
  - community.general.docker_image:
    name: hyperledger/fabric-ccenv:amd64-1.4.4
    source: pull

Upvotes: 5

Related Questions