containers.podman.podman_unshare become – Выполнение задач с использованием podman unshare
Примечание
Этот плагин become входит в коллекцию containers.podman (версия 1.16.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» здесь не допустимо). Настройка:
|
Примеры
- 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–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/containers/podman/podman_unshare_become.html