Commit Graph

21 Commits (217a18839d613823c1f0eb58e62e7606f7eb8d7c)

Author SHA1 Message Date
Peter Siegel 06df717bc6
lxd_connection: Allow non-root users to connect to an instance (#9659)
* fix: add support for non-root user

* fix: show correct info for connection

* fix: use build_exec_command to execute as nonroot

* unset default user

* feat: add options for setting remote user and become method

* fix: add root as default remote_user

* fix: remove ansible_ssh_user from remote_user vars

* fix: use single quotes inside f-string

* fix: ensure lxc exec comes first

* fix: line length

* fix: use -c flag with su

* Update plugins/connection/lxd.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/connection/lxd.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/connection/lxd.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* doc: add changelog fragment

* fix: use underscore for module name in fragment

* Update 9659-lxd_connection-nonroot-user.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix: add put command

* feat: add get_remote_uid_gid placeholder function

* feat: complete placeholder _get_remote_uid_gid function

* fix: better logging

* fix: ensure default values are of type str

* fix: use ints for uid and gid

* fix: print put command

* fix: format

* fix: display msg for PUT

* fix: add comment about defaults

* fix: format

* fix: use os module to get uid and gid

* Revert "fix: use os module to get uid and gid"

This reverts commit bb2ba14b8f.

* Update plugins/connection/lxd.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix: omit uid, gid args in lxd file push if root

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
2025-02-15 13:00:14 +01:00
Alexei Znamensky bd864c45ff
connection/inventory: adjust import __future__ for Python3 (#9584)
* connection/inventory: adjust import __future__ for Python3

* add changelog frag

* remove metaclass

* adjust chglog
2025-01-20 19:36:29 +01:00
Alexei Znamensky 040cd0ca50
normalize docs in cache/connection plugins (#9453)
Normalize doc blocks for plugins
2024-12-29 13:34:33 +01:00
Felix Fontein 2203560867
plugins: replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting (#9379)
* Replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting.

* Improve formulation.

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

* Use more f-strings.

* Remove unicode prefix for strings.

---------

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
2024-12-28 22:47:18 +01:00
Alexei Znamensky d539b00d4c
connection plugins: use f-strings (#9322)
* connection plugins: use f-strings

* add changelog frag
2024-12-24 12:00:19 +01:00
Felix Fontein ce65eb8736
Type options of connection plugins (#8627)
Type options of connection plugins.
2024-07-21 21:04:53 +02:00
Simon Deziel 13e3161f2a
Refer to LXD containers/VMs as instances (#7873)
* plugins/connection/lxd: rename container to instance

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>

* plugins/inventory/lxd: rename container to instance

It seems that a previous search and replace was done but it
missed those `containe_name` due to missing `r` in `container`.

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>

---------

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
2024-01-24 13:35:17 +01:00
Tim Small b4a2e9da50
Lxd instance not found fix false positives (#7521)
* lxd: Add lxc command execution debug statement.

* lxd: avoid false positives in "instance not found" detection

Due to changes over time in the error message which lxd printed when an
instance wasn't found, the detection logic in the lxd connection plugin
matched any "not found" string.  Unfortunately this also false triggered
on other errors e.g. "/usr/bin/python3: not found" from the payload,
giving a confusing error message "UNREACHABLE! ... instance not found"
to the ansible user.

* Update changelog fragment.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
2023-12-03 09:41:04 +01:00
Simon Deziel c7150dd818
plugins/connection/lxd: convert FQDN to instance name (#7360)
* plugins/connection/lxd: convert FQDN to instance name

This allows to use FQDNs in the inventory and have the
connection driver do the translation when talking to
LXD that uses hostnames (no ".") for instance names.
Those are either globally unique or unique per network/
project in LXD.

```
all:
  # Groups and hosts
  children:
    lxd_dmz:
      vars:
        ansible_lxd_project: dmz
      hosts:
        www01.dmz.example.com:
        www02.dmz.example.com:
```

```
$ lxc list --project dmz
+---------+---------+----------------+------+-----------+-----------+----------+
|  NAME |  STATE  |        IPV4      | IPV6 |   TYPE    | SNAPSHOTS | LOCATION |
+-------+---------+------------------+------+-----------+-----------+----------+
| www01 | RUNNING | 192.0.2.1 (eth0) |      | CONTAINER | 0         | t1       |
+-------+---------+------------------+------+-----------+-----------+----------+
| www02 | RUNNING | 192.0.2.2 (eth0) |      | CONTAINER | 0         | t3       |
+-------+---------+------------------+------+-----------+-----------+----------+
```

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>

* plugins/connection/lxd: VMs/containers are called instances

Update error string parsing to support the new format:

  $ lxc stop c1 -- true
  $ lxc exec c1 -- true
  Error: Instance is not running

  $ lxc exec does-not-exist -- true
  Error: Instance not found

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>

* plugins/connection/lxd: add changelog fragment

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>

---------

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
2023-10-25 08:47:27 +02:00
Felix Fontein 496bf27b5c
Fix copyright lines (make sure 'Copyright' is there). (#5083) 2022-08-05 22:12:10 +02:00
Felix Fontein 123c7efe5e
Move licenses to LICENSES/, run add-license.py, add LICENSES/MIT.txt (#5065)
* Move licenses to LICENSES/, run add-license.py, add LICENSES/MIT.txt.

* Replace 'Copyright:' with 'Copyright'

sed -i 's|Copyright:\(.*\)|Copyright\1|' $(rg -l 'Copyright:')

Co-authored-by: Maxwell G <gotmax@e.email>
2022-08-05 12:28:29 +02:00
antonc42 905f9ec399
fix lxd connection plugin inventory_hostname (#4912)
* fixes lxd connection plugin issue #4886

remote_addr value was set to literal string 'inventory_hostname' instead
of the value for inventory_hostname variable. solution found in PR
ansible/ansible#77894

* changelog fragment - bugfix - lxd connection plugin

* correct changelog fragment

* Update changelogs/fragments/4886-fix-lxd-inventory-hostname.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* replace _host instance variable with calls to get 'remote_addr' option

suggested by felixfontein

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-07-07 21:49:10 +02:00
Felix Fontein 77b7b4f75b
Get rid of distutils.spawn and distutils.util (#3934)
* Replace distutils.spawn.find_executable.

* Replace distutils.util.strtobool.
2022-01-04 06:56:28 +01:00
Conner Crosby 8f6866dba6
Update lxd connection to use all documented vars for options (#3798)
* Update lxd connection to use documented vars

* Add a changelog fragment

* Add clarification to changelog description

* Shorten changelog fragment description
2021-12-09 21:18:39 +01:00
Alexei Znamensky da11a98cb7
fixed the utf-8 marker (#3162) 2021-08-07 15:02:21 +02:00
Alexei Znamensky 73c27d6a0e
utf8 marker batch1 (#3127)
* added utf-8 markers to all .py files in plugins/{action,cache,callback}

* added utf-8 markers to all .py files in plugins/connection

* added utf-8 markers to all .py files in plugins/doc_fragments
2021-08-01 12:35:08 +02:00
Felix Fontein fafabed9e6
Replace ansible.module_utils._text by ansible.module_utils.common.text.converters (#2877)
* Replace ansible.module_utils._text by ansible.module_utils.common.text.converters.

* Also adjust tests.
2021-06-26 23:59:11 +02:00
Felix Fontein 99cfb993d5
<plugin_type>: -> name: (#1541) 2021-01-12 07:12:03 +01:00
Ishwar Kanse 6528aefcb5
Added support for remote project in the LXD connection plugin (#1515) 2021-01-04 11:00:47 +05:30
Felix Fontein e5da25915d
Improve plugin sanity (#966)
* callback_type -> type.

* Mark authors as unknown.

* Add author field forgotten in #627.

* Fix author entries.

* Add author field forgotten in #127.

* Fix some types.
2020-09-28 21:21:51 +02:00
Ansible Core Team aebc1b03fd Initial commit 2020-03-09 09:11:07 +00:00