Bonjour
My task:
- name: "MongoDB Operate | Create user - {{ mongo_metrics_exporter_user }}"
community.docker.docker_container_exec:
container: "{{ app_name }}-{{ allocation_id.stdout }}"
command: "mongosh admin -u {{ mongo_root_username }} -p {{ mongo_root_password }} < metrics_exporter_user.js"
chdir: "/data/db"
Result:
FAILED - RETRYING: [pc09.quanticware.com]: MongoDB Operate | Create user - exporter (9 retries left).Result was: changed=true
attempts: 2
invocation:
module_args:
api_version: auto
argv: null
ca_path: null
chdir: /data/db
client_cert: null
client_key: null
command: mongosh admin -u <user> -p <password> metrics_exporter_user.js
container: mongo-63aab8de-4a87-75ee-84b0-690f93909cd8
debug: false
detach: false
docker_host: unix:///var/run/docker.sock
env: null
ssl_version: null
stdin: null
stdin_add_newline: true
strip_empty_ends: true
timeout: 60
tls: false
tls_hostname: null
tty: false
use_ssh_client: false
user: null
validate_certs: false
rc: 1
retries: 11
stderr: 'Error: ENOENT: no such file or directory, open ''/data/db/<'''
stderr_lines: <omitted>
stdout: ''
stdout_lines: <omitted>
But when I’m connected to container:
root@f17f90a1de26:~# stat /data/db/metrics_exporter_user.js
File: /data/db/metrics_exporter_user.js
Size: 147 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 850160 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-08-19 15:54:16.744183518 +0000
Modify: 2024-08-19 15:31:47.960334327 +0000
Change: 2024-08-19 15:54:12.880228729 +0000
Birth: 2024-08-19 15:54:10.912251755 +0000
And if I try:
cd /data/db
mongosh admin -u <user> -p <password> metrics_exporter_user.js
It works!
Has anyone had this problem before? And solution?
Thanks!