From d2db3c3840228de22c30ed9b5aaf582d234620cb Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 7 Nov 2024 12:29:20 +0000 Subject: [PATCH 1/4] Begin v0.3.18dev --- docs/changelog.rst | 5 +++++ mitogen/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 0dede63a3..17f88aff2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -18,6 +18,11 @@ To avail of fixes in an unreleased version, please download a ZIP file `directly from GitHub `_. +In progress (unreleased) +------------------------ + + + v0.3.17 (2024-11-07) -------------------- diff --git a/mitogen/__init__.py b/mitogen/__init__.py index cbc58655c..73db5b8c5 100644 --- a/mitogen/__init__.py +++ b/mitogen/__init__.py @@ -35,7 +35,7 @@ #: Library version as a tuple. -__version__ = (0, 3, 17) +__version__ = (0, 3, 18, 'dev') #: This is :data:`False` in slave contexts. Previously it was used to prevent From e120cd2caeb41fccd2502b427628ff9ff6b66ac3 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 7 Nov 2024 14:18:58 +0000 Subject: [PATCH 2/4] ansible_mitogen: Templated become method --- ansible_mitogen/transport_config.py | 2 +- docs/changelog.rst | 2 ++ tests/ansible/hosts/default.hosts | 1 + tests/ansible/integration/become/templated_by_inv.yml | 1 + .../ansible/integration/become/templated_by_play_keywords.yml | 2 ++ tests/ansible/integration/become/templated_by_play_vars.yml | 2 ++ .../ansible/integration/become/templated_by_task_keywords.yml | 4 ++++ tests/ansible/templates/test-targets.j2 | 1 + 8 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index e4de34f1a..2218a7fa7 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -478,7 +478,7 @@ def become_flags(self): return self._become_option('become_flags') def become_method(self): - return self._play_context.become_method + return self._connection.become.name def become_user(self): return self._become_option('become_user') diff --git a/docs/changelog.rst b/docs/changelog.rst index 17f88aff2..08206b21d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,8 @@ To avail of fixes in an unreleased version, please download a ZIP file In progress (unreleased) ------------------------ +* :gh:issue:`1083` :mod:`ansible_mitogen`: Templated become method + (e.g. ``ansible_become_method``). v0.3.17 (2024-11-07) diff --git a/tests/ansible/hosts/default.hosts b/tests/ansible/hosts/default.hosts index 6bb21fc6c..42ca4ca62 100644 --- a/tests/ansible/hosts/default.hosts +++ b/tests/ansible/hosts/default.hosts @@ -32,6 +32,7 @@ ansible_user="{{ lookup('pipe', 'whoami') }}" [tt_become_by_inv] tt-become-exe ansible_become=true ansible_become_exe="{{ 'sudo' | trim }}" ansible_become_user=root tt-become-flags ansible_become=true ansible_become_flags="{{ '--set-home --stdin --non-interactive' | trim }}" ansible_become_user=root +tt-become-method ansible_become=true ansible_become_method="{{ 'sudo' | trim }}" ansible_become_user=root tt-become-pass ansible_become=true ansible_become_pass="{{ 'pw_required_password' | trim }}" ansible_become_user=mitogen__pw_required tt-become-user ansible_become=true ansible_become_user="{{ 'root' | trim }}" diff --git a/tests/ansible/integration/become/templated_by_inv.yml b/tests/ansible/integration/become/templated_by_inv.yml index a65fcf7bd..25df14e7f 100644 --- a/tests/ansible/integration/become/templated_by_inv.yml +++ b/tests/ansible/integration/become/templated_by_inv.yml @@ -14,6 +14,7 @@ expected_become_users: tt-become-exe: root tt-become-flags: root + tt-become-method: root tt-become-pass: mitogen__pw_required tt-become-user: root command: diff --git a/tests/ansible/integration/become/templated_by_play_keywords.yml b/tests/ansible/integration/become/templated_by_play_keywords.yml index 67d06125f..d3a87c928 100644 --- a/tests/ansible/integration/become/templated_by_play_keywords.yml +++ b/tests/ansible/integration/become/templated_by_play_keywords.yml @@ -4,6 +4,7 @@ become: true become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + become_method: "{{ 'sudo' | trim }}" become_user: "{{ 'root' | trim }}" tasks: - meta: reset_connection @@ -24,6 +25,7 @@ become: true become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + become_method: "{{ 'sudo' | trim }}" become_user: "{{ 'mitogen__pw_required' | trim }}" vars: ansible_become_pass: "{{ 'pw_required_password' | trim }}" diff --git a/tests/ansible/integration/become/templated_by_play_vars.yml b/tests/ansible/integration/become/templated_by_play_vars.yml index cdfb82217..df6684a50 100644 --- a/tests/ansible/integration/become/templated_by_play_vars.yml +++ b/tests/ansible/integration/become/templated_by_play_vars.yml @@ -5,6 +5,7 @@ ansible_become: true ansible_become_exe: "{{ 'sudo' | trim }}" ansible_become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + ansible_become_method: "{{ 'sudo' | trim }}" ansible_become_user: "{{ 'root' | trim }}" tasks: - name: Templated become by play vars, no password @@ -24,6 +25,7 @@ ansible_become: true ansible_become_exe: "{{ 'sudo' | trim }}" ansible_become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + ansible_become_method: "{{ 'sudo' | trim }}" ansible_become_pass: "{{ 'pw_required_password' | trim }}" ansible_become_user: "{{ 'mitogen__pw_required' | trim }}" tasks: diff --git a/tests/ansible/integration/become/templated_by_task_keywords.yml b/tests/ansible/integration/become/templated_by_task_keywords.yml index baea51e7e..bb5e8aa00 100644 --- a/tests/ansible/integration/become/templated_by_task_keywords.yml +++ b/tests/ansible/integration/become/templated_by_task_keywords.yml @@ -6,6 +6,7 @@ become: true become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + become_method: "{{ 'sudo' | trim }}" become_user: "{{ 'root' | trim }}" tasks: - name: Reset connection to target that will be delegate_to @@ -19,6 +20,7 @@ become: true become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + become_method: "{{ 'sudo' | trim }}" become_user: "{{ 'root' | trim }}" delegate_to: "{{ groups.tt_become_bare[0] }}" command: @@ -39,6 +41,7 @@ become: true become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + become_method: "{{ 'sudo' | trim }}" become_user: "{{ 'mitogen__pw_required' | trim }}" vars: ansible_become_pass: "{{ 'pw_required_password' | trim }}" @@ -60,6 +63,7 @@ become: true become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" + become_method: "{{ 'sudo' | trim }}" become_user: "{{ 'mitogen__pw_required' | trim }}" delegate_to: "{{ groups.tt_become_bare[0] }}" vars: diff --git a/tests/ansible/templates/test-targets.j2 b/tests/ansible/templates/test-targets.j2 index cebf70678..d4a0c60ee 100644 --- a/tests/ansible/templates/test-targets.j2 +++ b/tests/ansible/templates/test-targets.j2 @@ -59,6 +59,7 @@ ansible_user=mitogen__has_sudo_nopw [tt_become_by_inv] tt-become-exe ansible_become=true ansible_become_exe="{{ '{{' }} 'sudo' | trim {{ '}}' }}" ansible_become_user=root tt-become-flags ansible_become=true ansible_become_flags="{{ '{{' }} '--set-home --stdin --non-interactive' | trim {{ '}}' }}" ansible_become_user=root +tt-become-method ansible_become=true ansible_become_method="{{ '{{' }} 'sudo' | trim {{ '}}' }}" ansible_become_user=root tt-become-pass ansible_become=true ansible_become_pass="{{ '{{' }} 'pw_required_password' | trim {{ '}}' }}" ansible_become_user=mitogen__pw_required tt-become-user ansible_become=true ansible_become_user="{{ '{{' }} 'root' | trim {{ '}}' }}" From dd41ddf89b66047a66508a333dbc70aea933a4a8 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 7 Nov 2024 15:07:59 +0000 Subject: [PATCH 3/4] ansible_mitogen: Templated become flag The code change to support this was already made in transport_config.py, as part of templated become_user support (commit bf6607e27e01, PR #1148). This commit adds tests to confirm the functionality. --- docs/changelog.rst | 2 ++ tests/ansible/hosts/default.hosts | 1 + tests/ansible/integration/become/templated_by_inv.yml | 1 + .../integration/become/templated_by_play_keywords.yml | 4 ++-- .../integration/become/templated_by_task_keywords.yml | 8 ++++---- tests/ansible/templates/test-targets.j2 | 1 + 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 08206b21d..b0e4ede28 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,8 @@ In progress (unreleased) * :gh:issue:`1083` :mod:`ansible_mitogen`: Templated become method (e.g. ``ansible_become_method``). +* :gh:issue:`1083` :mod:`ansible_mitogen`: Templated become flag + (e.g. ``ansible_become_method``, ``become`` keyword). v0.3.17 (2024-11-07) diff --git a/tests/ansible/hosts/default.hosts b/tests/ansible/hosts/default.hosts index 42ca4ca62..17d1fd6d6 100644 --- a/tests/ansible/hosts/default.hosts +++ b/tests/ansible/hosts/default.hosts @@ -30,6 +30,7 @@ ansible_host=localhost ansible_user="{{ lookup('pipe', 'whoami') }}" [tt_become_by_inv] +tt-become ansible_become="{{ 'true' | trim }}" ansible_become_user=root tt-become-exe ansible_become=true ansible_become_exe="{{ 'sudo' | trim }}" ansible_become_user=root tt-become-flags ansible_become=true ansible_become_flags="{{ '--set-home --stdin --non-interactive' | trim }}" ansible_become_user=root tt-become-method ansible_become=true ansible_become_method="{{ 'sudo' | trim }}" ansible_become_user=root diff --git a/tests/ansible/integration/become/templated_by_inv.yml b/tests/ansible/integration/become/templated_by_inv.yml index 25df14e7f..0829fc084 100644 --- a/tests/ansible/integration/become/templated_by_inv.yml +++ b/tests/ansible/integration/become/templated_by_inv.yml @@ -12,6 +12,7 @@ - name: Templated become in inventory vars: expected_become_users: + tt-become: root tt-become-exe: root tt-become-flags: root tt-become-method: root diff --git a/tests/ansible/integration/become/templated_by_play_keywords.yml b/tests/ansible/integration/become/templated_by_play_keywords.yml index d3a87c928..146a37352 100644 --- a/tests/ansible/integration/become/templated_by_play_keywords.yml +++ b/tests/ansible/integration/become/templated_by_play_keywords.yml @@ -1,7 +1,7 @@ - name: integration/become/templated_by_play_keywords.yml hosts: tt_become_bare gather_facts: false - become: true + become: "{{ 'true' | trim }}" become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" become_method: "{{ 'sudo' | trim }}" @@ -22,7 +22,7 @@ - name: integration/become/templated_by_play_keywords.yml hosts: tt_become_bare gather_facts: false - become: true + become: "{{ 'true' | trim }}" become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" become_method: "{{ 'sudo' | trim }}" diff --git a/tests/ansible/integration/become/templated_by_task_keywords.yml b/tests/ansible/integration/become/templated_by_task_keywords.yml index bb5e8aa00..c42df1b1e 100644 --- a/tests/ansible/integration/become/templated_by_task_keywords.yml +++ b/tests/ansible/integration/become/templated_by_task_keywords.yml @@ -3,7 +3,7 @@ gather_facts: false # FIXME Resetting the connection shouldn't require credentials # https://github.com/mitogen-hq/mitogen/issues/1132 - become: true + become: "{{ 'true' | trim }}" become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" become_method: "{{ 'sudo' | trim }}" @@ -17,7 +17,7 @@ gather_facts: false tasks: - name: Templated become by task keywords, with delegate_to - become: true + become: "{{ 'true' | trim }}" become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" become_method: "{{ 'sudo' | trim }}" @@ -38,7 +38,7 @@ gather_facts: false # FIXME Resetting the connection shouldn't require credentials # https://github.com/mitogen-hq/mitogen/issues/1132 - become: true + become: "{{ 'true' | trim }}" become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" become_method: "{{ 'sudo' | trim }}" @@ -60,7 +60,7 @@ setup: - name: Templated become by task keywords, with delegate_to - become: true + become: "{{ 'true' | trim }}" become_exe: "{{ 'sudo' | trim }}" become_flags: "{{ '--set-home --stdin --non-interactive' | trim }}" become_method: "{{ 'sudo' | trim }}" diff --git a/tests/ansible/templates/test-targets.j2 b/tests/ansible/templates/test-targets.j2 index d4a0c60ee..bb0d85ece 100644 --- a/tests/ansible/templates/test-targets.j2 +++ b/tests/ansible/templates/test-targets.j2 @@ -57,6 +57,7 @@ ansible_python_interpreter={{ tt.python_path }} ansible_user=mitogen__has_sudo_nopw [tt_become_by_inv] +tt-become ansible_become="{{ '{{' }} 'true' | trim {{ '}}' }}" ansible_become_user=root tt-become-exe ansible_become=true ansible_become_exe="{{ '{{' }} 'sudo' | trim {{ '}}' }}" ansible_become_user=root tt-become-flags ansible_become=true ansible_become_flags="{{ '{{' }} '--set-home --stdin --non-interactive' | trim {{ '}}' }}" ansible_become_user=root tt-become-method ansible_become=true ansible_become_method="{{ '{{' }} 'sudo' | trim {{ '}}' }}" ansible_become_user=root From d85d9a25ee02bddecf068b888c2d814cc918864c Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 7 Nov 2024 16:53:30 +0000 Subject: [PATCH 4/4] Prepare v0.3.18 --- docs/changelog.rst | 4 ++-- mitogen/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b0e4ede28..b4d370665 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -18,8 +18,8 @@ To avail of fixes in an unreleased version, please download a ZIP file `directly from GitHub `_. -In progress (unreleased) ------------------------- +v0.3.18 (2024-11-07) +-------------------- * :gh:issue:`1083` :mod:`ansible_mitogen`: Templated become method (e.g. ``ansible_become_method``). diff --git a/mitogen/__init__.py b/mitogen/__init__.py index 73db5b8c5..8addceb62 100644 --- a/mitogen/__init__.py +++ b/mitogen/__init__.py @@ -35,7 +35,7 @@ #: Library version as a tuple. -__version__ = (0, 3, 18, 'dev') +__version__ = (0, 3, 18) #: This is :data:`False` in slave contexts. Previously it was used to prevent