Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed by setuptools-scm
- name: Switch to using Python 3.9 by default
- name: Switch to using Python 3.11 by default
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ jobs:
strategy:
fail-fast: false
matrix:
toxenv: [docs, packaging, py39]
toxenv: [docs, packaging, py311]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
9 changes: 2 additions & 7 deletions images/debian_bookworm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,15 @@ RUN echo "user:foo" | chpasswd
RUN echo "*nat\n:PREROUTING ACCEPT [0:0]\n:INPUT ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n:POSTROUTING ACCEPT [0:0]\n-A PREROUTING -d 192.168.0.1/32 -j REDIRECT\nCOMMIT\n*filter\n:INPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT\nCOMMIT" > /etc/iptables/rules.v4

# Expiration date for user "user"
RUN chage -E 20000 -m 7 -M 90 user
RUN chage -E 2030-01-01 -m 7 -M 90 user

# Some python3 virtualenv
RUN virtualenv /v
RUN /v/bin/pip install -U pip
RUN /v/bin/pip install 'requests==2.30.0'

# install salt
ARG _BUILD_DEPS="gcc g++ libc6-dev python3-dev"
RUN apt update && apt install -y $_BUILD_DEPS && \
python3 -m pip install --break-system-packages --no-cache salt && \
apt -y purge $_BUILD_DEPS && \
apt -y autoremove --purge && \
rm -rf /var/lib/apt/lists/*
RUN python3 -m pip install --break-system-packages --no-cache salt tornado distro looseversion msgpack pyyaml packaging jinja2

ENV LANG fr_FR.ISO-8859-15
ENV LANGUAGE fr_FR
Expand Down
7 changes: 6 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ pytest-cov
pytest-xdist
paramiko
types-paramiko
salt
pywinrm
ansible
salt
# XXX: salt.client dependencies
tornado
distro
looseversion
msgpack
5 changes: 3 additions & 2 deletions test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ def test_encoding(host):
elif host.backend.get_connection_type() == "ansible" and host.backend.force_ansible:
# XXX: this encoding issue comes directly from ansible
# not sure how to handle this...
assert cmd.stderr == (
"ls: impossible d'accéder à '/é': " "Aucun fichier ou dossier de ce type"
assert (
cmd.stderr
== "ls: impossible d'acc\udce9der \udce0 '/é': Aucun fichier ou dossier de ce type"
)
else:
assert cmd.stderr_bytes == (
Expand Down
2 changes: 1 addition & 1 deletion test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_user_user(host):

def test_user_expiration_date(host):
assert host.user("root").expiration_date is None
assert host.user("user").expiration_date == (datetime.datetime(2024, 10, 4, 0, 0))
assert host.user("user").expiration_date == datetime.datetime(2030, 1, 1)


def test_nonexistent_user(host):
Expand Down
16 changes: 10 additions & 6 deletions testinfra/backend/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import logging
import pprint
from typing import Any, Optional
Expand Down Expand Up @@ -56,12 +57,15 @@ def run(self, command: str, *args: str, **kwargs: Any) -> base.CommandResult:
if host is not None:
return host.run(command)
out = self.run_ansible("shell", module_args=command, check=False)
return self.result(
out["rc"],
self.encode(command),
out["stdout"],
out["stderr"],
)
if "module_stdout" in out:
data = json.loads(out["module_stdout"])
stdout = data["stdout"]
stderr = data["stderr"]
else:
# bw compat
stdout = out["stdout"]
stderr = out["stderr"]
return self.result(out["rc"], self.encode(command), stdout, stderr)

def run_ansible(
self, module_name: str, module_args: Optional[str] = None, **kwargs: Any
Expand Down