-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
incus_connection: Allow non-root users to connect to an instance #9743
incus_connection: Allow non-root users to connect to an instance #9743
Conversation
Can be tested with: - name: Create an incus container
hosts: localhost
gather_facts: true
tasks:
- name: Create a container
community.general.lxd_container:
name: "jammy"
state: started
url: "unix:/var/lib/incus/unix.socket"
source:
type: image
mode: pull
server: "https://images.linuxcontainers.org/"
protocol: simplestreams
alias: "ubuntu/jammy/cloud"
wait_for_container: true
wait_for_ipv4_addresses: true
- name: Add the container to the inventory
ansible.builtin.add_host:
name: "jammy"
groups:
- incus
ansible_connection: community.general.incus
ansible_user: ubuntu
- name: Run tasks in the container
hosts: incus
gather_facts: true
tasks:
- name: Create a file in the container
ansible.builtin.copy:
content: "Hello World!\n"
dest: "{{ ansible_env.HOME }}/hello.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From an Ansible perspective, looks OK.
LGTM |
Backport to stable-10: 💚 backport PR created✅ Backport PR branch: Backported as #9765 🤖 @patchback |
* feat: add remote_user option to incus connection * feat: add changelog fragment * fix: formatting (cherry picked from commit 94e1511)
@yeetypete thanks for your contribution! |
…oot users to connect to an instance (#9765) incus_connection: Allow non-root users to connect to an instance (#9743) * feat: add remote_user option to incus connection * feat: add changelog fragment * fix: formatting (cherry picked from commit 94e1511) Co-authored-by: Peter Siegel <[email protected]>
…ible-collections#9743) * feat: add remote_user option to incus connection * feat: add changelog fragment * fix: formatting
SUMMARY
Currently the incus connection only supports connecting to an instance as root. This PR extends the plugin to allow a non-root user, configurable via the ansible_user var to connect to the instance. The option incus_become_method controls the command used to switch users, (su by default but could also be sudo -u). The defaults ensure the old behavior so this should be a non-breaking change.
ISSUE TYPE
COMPONENT NAME
incus_connection
ADDITIONAL INFORMATION
Replicates functionality from #9659 for the incus plugin