lueschem / edi

Embedded development infrastructure.
https://www.get-edi.io
GNU Lesser General Public License v3.0
38 stars 12 forks source link

Development container build fails without sudo #65

Closed lueschem closed 3 years ago

lueschem commented 3 years ago

Issue Type

Environment detail

+ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
+ python3 --version
Python 3.8.5
+ ansible-playbook --version
ansible-playbook 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/lueschm1/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
+ lxc --version
4.0.4
+ dpkg+  -l
grep \(lxd\|ansible\)
ii  ansible                                    2.9.6+dfsg-1                         all          Configuration management, deployment, and task execution system
ii  lxd                                        1:0.9                                all          Transitional package - lxd -> snap (lxd)

Desired Behavior

The build shall work without sudo as edi is not requesting it.

Actual Behavior

With sudo - OK

sudo edi --log=DEBUG lxc configure edi-pi-cross-dev-buster pi-buster-arm64-cross-dev.yml

...

TASK [shared_folder_mountpoints : Add mount points for shared folders within the directory of the current user.] ****************************************************************************************************************************
task path: /usr/lib/python3/dist-packages/edi/plugins/playbooks/debian/development_user_facilities/roles/shared_folder_mountpoints/tasks/main.yml:2
Using module file /usr/lib/python3/dist-packages/ansible/modules/files/file.py
Pipelining is enabled.
<edi-pi-cross-dev-buster> ESTABLISH LXD CONNECTION FOR USER: root
<edi-pi-cross-dev-buster> EXEC /bin/sh -c 'sudo -H -S -n  -u lueschm1 /bin/sh -c '"'"'echo BECOME-SUCCESS-jmdtochfmcbslmbsewwqubtanlcdykrz ; /usr/bin/python3'"'"' && sleep 0'
...

Without sudo - FAILURE

edi --log=DEBUG lxc configure edi-pi-cross-dev-buster pi-buster-arm64-cross-dev.yml

TASK [shared_folder_mountpoints : Add mount points for shared folders within the directory of the current user.] ****************************************************************************************************************************
task path: /usr/lib/python3/dist-packages/edi/plugins/playbooks/debian/development_user_facilities/roles/shared_folder_mountpoints/tasks/main.yml:2
Using module file /usr/lib/python3/dist-packages/ansible/modules/files/file.py
Pipelining is enabled.
<edi-pi-cross-dev-buster> ESTABLISH LXD CONNECTION FOR USER: root
<edi-pi-cross-dev-buster> EXEC /bin/sh -c 'sudo -H -S -n  -u lueschm1 /bin/sh -c '"'"'echo BECOME-SUCCESS-uatygdhwxhrxwajuuqhqncghytfxljkv ; /usr/bin/python3'"'"' && sleep 0'
The full traceback is:
  File "/tmp/ansible_file_payload_1m3wqwa1/ansible_file_payload.zip/ansible/module_utils/basic.py", line 735, in tmpdir
    tmpdir = tempfile.mkdtemp(prefix=basefile, dir=basedir)
  File "/usr/lib/python3.7/tempfile.py", line 505, in mkdtemp
    _os.mkdir(file, 0o700)
failed: [edi-pi-cross-dev-buster] (item=/home/lueschm1/edi-workspace) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": null,
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "backup": null,
            "content": null,
            "delimiter": null,
            "directory_mode": null,
            "follow": true,
            "force": false,
            "group": null,
            "mode": null,
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "owner": null,
            "path": "/home/lueschm1/edi-workspace",
            "recurse": false,
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "directory",
            "unsafe_writes": null
        }
    },
    "item": "/home/lueschm1/edi-workspace",
    "msg": "Failed to create remote module tmp path at dir /tmp/ansible-lueschm1 with prefix ansible-moduletmp-1607009291.9104812-: [Errno 13] Permission denied: '/tmp/ansible-lueschm1/ansible-moduletmp-1607009291.9104812-nrxb6lux'"
}