ansible-role-docker-rootless icon indicating copy to clipboard operation
ansible-role-docker-rootless copied to clipboard

.bashrc generation tasks problem

Open scicco opened this issue 1 year ago • 7 comments

Hello,

i'm finding a strange issue with stat tasks inside bashrc.yml

my local configuration

$ ansible --version
ansible [core 2.14.4]
  config file = None
  configured module search path = ['/Users/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/myuser/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.3 (main, Apr  7 2023, 21:05:46) [Clang 14.0.0 (clang-1400.0.29.202)] (/opt/homebrew/opt/[email protected]/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
# ansible-galaxy --version
ansible-galaxy [core 2.14.4]
  config file = None
  configured module search path = ['/Users/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/myuser/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible-galaxy
  python version = 3.11.3 (main, Apr  7 2023, 21:05:46) [Clang 14.0.0 (clang-1400.0.29.202)] (/opt/homebrew/opt/[email protected]/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
$ ansible-galaxy list | grep docker_rootless
- konstruktoid.docker_rootless, v0.15.0

The destination server configuration:

# uname -a
Linux <XXXX> 5.15.0-70-generic #77-Ubuntu SMP Tue Mar 21 14:02:37 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
# python3 --version
Python 3.10.6

this is my role task content:

...
- name: Install Docker rootless
  include_role:
    name: konstruktoid.docker_rootless
  vars:
    docker_user: "{{ provisioning_username | mandatory }}"
    docker_compose: true
    docker_user_bashrc: true
...

this is the command output of

ansible-playbook -u root -i inventories/test/hosts webserver.yml -vvv --extra-vars "var_files_path=./inventories/test/host_vars/default.yml"

I'm connecting as root to the server. The {{provisioning_username}} variable is "deployer" which was created in a previous task

command output:

...
...
TASK [konstruktoid.docker_rootless : Stat Docker user .bashrc] *********************************************************************************************************************************************
task path: /Users/myuser/.ansible/roles/konstruktoid.docker_rootless/tasks/bashrc.yml:2

ok: [[email protected]] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "checksum_algorithm": "sha1",
            "follow": false,
            "get_attributes": true,
            "get_checksum": true,
            "get_md5": false,
            "get_mime": true,
            "path": "/home/deployer/.bashrc"
        }
    },
    "stat": {
        "exists": false
    }
}

TASK [konstruktoid.docker_rootless : Create Docker user .bashrc] *******************************************************************************************************************************************
task path: /Users/myuser/.ansible/roles/konstruktoid.docker_rootless/tasks/bashrc.yml:8
fatal: [[email protected]]: FAILED! => {
    "msg": "The conditional check 'not docker_user_bashrc.stat.exists' failed. The error was: error while evaluating conditional (not docker_user_bashrc.stat.exists): 'bool object' has no attribute 'stat'. 'bool object' has no attribute 'stat'\n\nThe error appears to be in '/Users/myuser/.ansible/roles/konstruktoid.docker_rootless/tasks/bashrc.yml': line 8, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Create Docker user .bashrc\n  ^ here\n"
}

The previous times I used my procedure ran smoothly, in particular the docker rootless installation part, based on your awesome project.

What's wrong this time?

Thank you in advance

scicco avatar Apr 21 '23 13:04 scicco

Hi @scicco, and thanks for the kind words.

I haven't seen this behaviour before, so I'll have to run some tests.

I'll reply as soon as possible.

konstruktoid avatar Apr 21 '23 13:04 konstruktoid

thank you @konstruktoid. Meanwhile, I was able to proceed by changing this line in https://github.com/konstruktoid/ansible-role-docker-rootless/blob/09587a76b68d5028d28d39cc53c4d1d9dd52eeca/tasks/bashrc.yml#L17

in:

when: not docker_user_bashrc

but it still seems strange to me

scicco avatar Apr 24 '23 12:04 scicco

Thanks for testing, I haven't gotten around to proper test this issue as you've noticed.

Seems it should return the same result?

But I'll have a look.

konstruktoid avatar Apr 24 '23 12:04 konstruktoid

Sorry for the delay, but I can't reproduce this.

konstruktoid avatar Apr 27 '23 19:04 konstruktoid

I am having the same issue.


michael@Michaels-MacBook-Pro provision-server % ansible --version
ansible [core 2.15.3]
  config file = None
  configured module search path = ['/Users/michael/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/michael/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] 
  jinja version = 3.1.2
  libyaml = True

mbwmbw1337 avatar Sep 08 '23 23:09 mbwmbw1337

Related https://github.com/konstruktoid/ansible-role-docker-rootless/issues/209

konstruktoid avatar Dec 21 '23 12:12 konstruktoid

Can you reproduce this?

konstruktoid avatar Dec 27 '23 22:12 konstruktoid