Commit graph

46 commits

Author SHA1 Message Date
Peter Siegel
bb2ba14b8f
fix: use os module to get uid and gid 2025-02-10 11:13:04 +01:00
Peter Siegel
06fb16c658
fix: format 2025-02-02 13:48:18 +01:00
Peter Siegel
bb3262079b
fix: add comment about defaults 2025-02-02 13:44:21 +01:00
Peter Siegel
e2d3fe7a1c
fix: display msg for PUT 2025-02-02 13:35:36 +01:00
Peter Siegel
ab11857bc0
fix: format 2025-02-02 13:34:35 +01:00
Peter Siegel
b2583960c0
fix: print put command 2025-02-02 11:08:39 +01:00
Peter Siegel
894c28fa28
fix: use ints for uid and gid 2025-02-02 10:39:24 +01:00
Peter Siegel
bdb9ab354f
fix: ensure default values are of type str 2025-02-02 02:34:42 +01:00
Peter Siegel
478b25c636
fix: better logging 2025-02-02 02:30:09 +01:00
Peter Siegel
cce1c3c099
feat: complete placeholder _get_remote_uid_gid function 2025-02-02 02:23:54 +01:00
Peter Siegel
b27fdf07c7
feat: add get_remote_uid_gid placeholder function 2025-02-02 02:11:51 +01:00
Peter Siegel
4eb496c1ea
fix: add put command 2025-02-02 01:55:59 +01:00
Peter Siegel
e40b0e2be4
Update plugins/connection/lxd.py
Co-authored-by: Felix Fontein <felix@fontein.de>
2025-01-31 22:45:14 +01:00
Peter Siegel
42a51c9b01
Update plugins/connection/lxd.py
Co-authored-by: Felix Fontein <felix@fontein.de>
2025-01-31 22:44:54 +01:00
Peter Siegel
553f38ac98
Update plugins/connection/lxd.py
Co-authored-by: Felix Fontein <felix@fontein.de>
2025-01-31 22:44:44 +01:00
Peter Siegel
fe0add095c
fix: use -c flag with su 2025-01-31 22:21:04 +01:00
Peter Siegel
297f3c0f9a
fix: line length 2025-01-31 20:41:02 +01:00
Peter Siegel
30a6f46570
fix: ensure lxc exec comes first 2025-01-31 20:41:02 +01:00
Peter Siegel
845705665f
fix: use single quotes inside f-string 2025-01-31 20:41:02 +01:00
Peter Siegel
daf5eaa20a
fix: remove ansible_ssh_user from remote_user vars 2025-01-31 20:41:02 +01:00
Peter Siegel
de8272c1f1
fix: add root as default remote_user 2025-01-31 20:41:02 +01:00
Peter Siegel
4a661375bb
feat: add options for setting remote user and become method 2025-01-31 20:41:02 +01:00
Peter Siegel
28fb13bdff
unset default user 2025-01-31 20:41:02 +01:00
Peter Siegel
4ebd4a6efe
fix: use build_exec_command to execute as nonroot 2025-01-31 20:41:02 +01:00
Peter Siegel
bb81a7bb11
fix: show correct info for connection 2025-01-31 20:41:02 +01:00
Peter Siegel
433ed7c030
fix: add support for non-root user 2025-01-31 20:40:59 +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