I've tried this:
- name: Log into Docker registry
command: docker login --username "{{ docker_registry_username }}" --password-stdin
stdin: "{{ docker_registry_password }}"
This results in a warning and a failing command:
[WARNING]: Ignoring invalid attribute: stdin
…
Cannot perform an interactive login from a non TTY device
I've also tried this:
- name: Log into Docker registry
command: docker login --username "{{ docker_registry_username }}" --password-stdin
stdin: "{{ docker_registry_password }}"
This results in a syntax error:
ERROR! Syntax Error while loading YAML.
Does command
stdin
actually work in Ansible 2.7? If so, how am I supposed to use it?
If you want to use the stdin
argument to the command
module, take a look at the docs, which show examples using other options such as creates
, which looks like this:
# You can also use the 'args' form to provide the options.
- name: This command will change the working directory to somedir/ and will only run when /path/to/database doesn't exist.
command: /usr/bin/make_database.sh arg1 arg2
args:
chdir: somedir/
creates: /path/to/database
For your use case, you would want:
- name: Log into Docker registry
command: docker login --username "{{ docker_registry_username }}" --password-stdin
args:
stdin: "{{ docker_registry_password }}"
Your first attempt failed because you were setting stdin
as a key at the task level (like when
or ignore_errors
, etc), when you actually want it to be an argument to the command
module.
Your second attempt failed because it wasn't valid YAML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With