containers.podman.podman_unshare become – Выполнение задач с помощью podman unshare
Примечание
Этот плагин become входит в коллекцию containers.podman (версия 1.20.1).
Возможно, эта коллекция уже установлена, если вы используете пакет ansible. Она не входит в ansible-core. Чтобы проверить, установлена ли она, выполните ansible-galaxy collection list.
Для установки используйте: ansible-galaxy collection install containers.podman.
Чтобы использовать её в плейбуке, укажите: containers.podman.podman_unshare.
Добавлено в containers.podman 1.9.0
Описание
- Этот плагин become позволяет удалённому пользователю или пользователю, выполнившему вход, выполнять команды в пространстве имён пользователей контейнера. Официальная документация: https://docs.podman.io/en/latest/markdown/podman-unshare.1.html
Параметры
Параметр | Комментарии |
|---|---|
become_exe строка | Исполняемый файл sudo По умолчанию: Конфигурация:
|
become_pass строка | Пароль для передачи sudo Конфигурация:
|
become_user строка | Пользователь, от имени которого выполняется задача (значение «root» здесь недопустимо). Конфигурация:
|
Примечание
Записи конфигурации, перечисленные выше для каждого типа записи (переменная Ansible, переменная среды и т. д.), упорядочены от низкого приоритета к высокому. Например, переменная, расположенная ниже в списке, переопределит переменную, расположенную выше. Типы записей также упорядочены по приоритету от низкого к высокому. Например, запись в ansible.cfg (расположенная выше в списке) переопределяется переменной Ansible (расположенной ниже в списке).
Примеры
- name: checking uid of file 'foo'
ansible.builtin.stat:
path: "{{ test_dir }}/foo"
register: foo
- ansible.builtin.debug:
var: foo.stat.uid
# The output shows that it's owned by the login user
# ok: [test_host] => {
# "foo.stat.uid": "1003"
# }
- name: mounting the file to an unprivileged container and modifying its owner
containers.podman.podman_container:
name: chmod_foo
image: alpine
rm: true
volume:
- "{{ test_dir }}:/opt/test:z"
command: chown 1000 /opt/test/foo
# Now the file 'foo' is owned by the container uid 1000,
# which is mapped to something completaly different on the host.
# It creates a situation when the file is unaccessible to the host user (uid 1003)
# Running stat again, debug output will be like this:
# ok: [test_host] => {
# "foo.stat.uid": "328679"
# }
- name: running stat in modified user namespace
become_method: containers.podman.podman_unshare
become: true
ansible.builtin.stat:
path: "{{ test_dir }}/foo"
register: foo
# By gathering file stats with podman_ushare
# we can see the uid set in the container:
# ok: [test_host] => {
# "foo.stat.uid": "1000"
# }
- name: resetting file ownership with podman unshare
become_method: containers.podman.podman_unshare
become: true
ansible.builtin.file:
state: file
path: "{{ test_dir }}/foo"
owner: 0 # in a modified user namespace host uid is mapped to 0
# If we run stat and debug with 'become: false',
# we can see that the file is ours again:
# ok: [test_host] => {
# "foo.stat.uid": "1003"
# }
Авторы
- Janos Gerzson (@grzs)
Ссылки на коллекцию
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/containers/podman/podman_unshare_become.html