Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman volume mount of single files are replaced by a directory mount rather than inserted correctly #1753

Open
hb9hnt opened this issue May 7, 2024 · 4 comments
Labels
bug Researched, reproducible, committed to fix

Comments

@hb9hnt
Copy link

hb9hnt commented May 7, 2024

ISSUE TYPE
  • Bug Report
SUMMARY

Ansible navigator breaks volume mounts if you try to mount a single file rather than a directory. Specifying the following mount

ansible-navigator:
  execution-environment:
    container-engine: podman
    volume-mounts:
      - src: /home/myuser/.ansible/linux_vault_key.txt
        dest: /var/tmp/vault-key.txt
        options: "ro"

leads to the following podman mount CLI option:

podman [...] -v /home/myuser/.ansible/:/var/tmp/:ro
ANSIBLE-NAVIGATOR VERSION
$ ansible-navigator --version
ansible-navigator 24.2.0
CONFIGURATION
---
ansible-navigator:
  logging:
    level: debug
  ansible-lint:
    config: .ansible-lint
  color:
    enable: True
  mode: stdout
  execution-environment:
    container-engine: podman
    environment-variables:
      set:
        ANSIBLE_VAULT_PASSWORD_FILE: /var/tmp/vault-key.txt
    volume-mounts:
      - src: /home/myuser/.ansible/linux_vault_key.txt
        dest: /var/tmp/vault-key.txt
        options: "ro"
    image:  gitlab.mydomain.com:5050/project/awx
    pull:
      policy: missing
LOG FILE

The relevant part of the debug log file has been mentioned above. The mount on the podman command doesn't look as specified:

podman [...] -v /home/myuser/.ansible/:/var/tmp/:ro

this leads to the following errors from ansible-playbook:

No config file found; using defaults
[WARNING]: Error getting vault password file (default): The vault password file
/var/tmp/vault-key.txt was not found
ERROR! The vault password file /var/tmp/vault-key.txt was not found
STEPS TO REPRODUCE

Specify a file mount rather than a directory mount as mentioned above.

EXPECTED RESULTS

The podman option that should be used is as follows:

podman [...] -v /home/myuser/.ansible/linux_vault_key.txt:/var/tmp/vault-key.txt:ro
ACTUAL RESULTS

Only a directory mount is inserted in the podman command

podman [...] -v /home/myuser/.ansible/:/var/tmp/:ro
@hb9hnt hb9hnt added bug Researched, reproducible, committed to fix new New issues and PRs to triaged labels May 7, 2024
@Qalthos Qalthos removed the new New issues and PRs to triaged label May 8, 2024
@ssbarnea
Copy link
Member

ssbarnea commented May 8, 2024

This looks like a valid bug. A PR would be welcomed here.

@hb9hnt
Copy link
Author

hb9hnt commented May 9, 2024

I looked into this a bit closer. It seems that this is a bug in ansible-runner that was introduced on purpose in another PR:

ansible/ansible-runner#728

to fix the following bug:

#471

As far as I can tell the bug has nothing to do with why we should only allow directory mounts rather than file mounts, too.

@cidrblock Would you happen to remember why it was necessary to disallow file mounts to fix the mentioned issue?

@marshallford
Copy link

Any resolution to this issue? Or is the outcome simply that file mounts should not be be used (based on the PR in ansible-runner it sure looks that way)?

Thanks!

@cidrblock
Copy link
Collaborator

I don't think the intent of that fix was to explicitely disallow file mount but instead to normalize the directory names in a manner they could be deduplicated. The missing ability to mount just a file is just an oversight as I think it's less commonly done.

I don't see a reason why individual file mounts would be an issue, although the runner code would need to be updated with an escape hatch to bypass the directory logic and let the file mount striaght through.

Good catch all.

The best path forward I think would be for an issue to be opened in the runner repo, linked back to this and a PR if anyone has time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Researched, reproducible, committed to fix
Projects
Status: No status
Development

No branches or pull requests

5 participants