Skip to content

Commit 0561d0a

Browse files
authored
Merge pull request #21 from serverscom/new_mitogen
feat: add support for new mitogen
2 parents 6ffa2d8 + b22f719 commit 0561d0a

File tree

7 files changed

+392
-357
lines changed

7 files changed

+392
-357
lines changed

Diff for: README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
This collection allows to use [Mitogen](https://github.com/mitogen-hq/mitogen)
44
strategy without the need to specify absolute path to the strategy file.
55

6-
It also performs live patching for Mitogen restrictions in Ansible
7-
versions, making it possible to use Mitogen with the current Ansible version.
6+
It also performs live patching for oler versions of Mitogen (3.4), removing
7+
Ansible version restrictions, making it possible to use Mitogen
8+
on unsupported versions.
89

910
Tested versions of ansible-core:
1011

1112
* 2.14
1213
* 2.15
1314
* 2.16
15+
* 2.17
1416

15-
It patches `ansible_mitogen` code and unpatches it
17+
When needed, it patches `ansible_mitogen` code and unpatches it
1618
back right after module import, so the original
1719
files are kept intact.
1820

21+
If no patching needed, it just passes mitogen content as it is.
22+
1923
## Install
2024
To use this collection, you need to install Mitogen:
2125

Diff for: galaxy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
namespace: serverscom
33
name: mitogen
4-
version: 1.3.6
4+
version: 1.4.0
55
readme: README.md
66
authors:
77
- Sergey Putko <[email protected]>

Diff for: plugins/strategy/mitogen_free.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,17 @@
3131
# You should have received a copy of the GNU General Public License
3232
# along with this program. If not, see <https://www.gnu.org/licenses/>.
3333

34+
import importlib.metadata
3435

35-
from . import patching
36+
try:
37+
mitogen_version = importlib.metadata.version("mitogen")
38+
except importlib.metadata.PackageNotFoundError:
39+
raise ImportError("Unable to load mitogen module.")
3640

37-
with patching.patch_version():
41+
if mitogen_version == "0.3.4":
42+
from . import patching
43+
44+
with patching.patch_version():
45+
from ansible_mitogen.plugins.strategy.mitogen_free import *
46+
else:
3847
from ansible_mitogen.plugins.strategy.mitogen_free import *

Diff for: plugins/strategy/mitogen_host_pinned.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@
1515
short_description: Mitogen patching strategy
1616
"""
1717

18-
from . import patching
18+
import importlib.metadata
1919

20-
with patching.patch_version():
20+
try:
21+
mitogen_version = importlib.metadata.version("mitogen")
22+
except importlib.metadata.PackageNotFoundError:
23+
raise ImportError("Unable to load mitogen module.")
24+
25+
if mitogen_version == "0.3.4":
26+
from . import patching
27+
28+
with patching.patch_version():
29+
from ansible_mitogen.plugins.strategy.mitogen_host_pinned import *
30+
else:
2131
from ansible_mitogen.plugins.strategy.mitogen_host_pinned import *

Diff for: plugins/strategy/mitogen_linear.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@
1515
short_description: Mitogen patching strategy
1616
"""
1717

18-
from . import patching
18+
import importlib.metadata
1919

20-
with patching.patch_version():
20+
try:
21+
mitogen_version = importlib.metadata.version("mitogen")
22+
except importlib.metadata.PackageNotFoundError:
23+
raise ImportError("Unable to load mitogen module.")
24+
25+
if mitogen_version == "0.3.4":
26+
from . import patching
27+
28+
with patching.patch_version():
29+
from ansible_mitogen.plugins.strategy.mitogen_linear import *
30+
else:
2131
from ansible_mitogen.plugins.strategy.mitogen_linear import *

Diff for: poetry.lock

+346-344
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ authors =["Sergey Putko <[email protected]>", "George Shuklin <geo
66
license = "BSD/MIT"
77

88
[tool.poetry.dependencies]
9-
python = ">=3.9, <3.12"
10-
ansible-core = ">=2.13, <2.17"
9+
python = ">=3.10, <3.13"
10+
ansible-core = ">=2.17, <2.18"
1111
black = "^23.1.0"
12-
mitogen = "0.3.4"
12+
mitogen = "0.3.12"
1313
molecule = ">=5.0.0"
1414
yamllint = "^1.29.0"
1515

0 commit comments

Comments
 (0)