Skip to content

Commit

Permalink
Additional tests
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde committed Mar 22, 2023
1 parent ee6fde3 commit dc425f3
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/python_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,22 @@ Usage examples
print("Final status:")
print(r.stats)
.. code-block:: python
import ansible_runner
# Specifying custom container working directory while using Podman
# `/tmp/demo` contains `my_project` directory which contains all the Ansible content
res = ansible_runner.run(
private_data_dir='/tmp/demo',
host_pattern='localhost',
container_workdir='/runner/my_project',
playbook='debug.yml',
process_isolation_executable='podman',
process_isolation=True,
container_image='quay.io/ansible/ansible-runner:devel',
)
stdout = res.stdout.read()
.. code-block:: python
from ansible_runner import Runner, RunnerConfig
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/projects/project_dir_test/project/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- hosts: all
gather_facts: no

tasks:
- debug:
msg: "In project"
48 changes: 48 additions & 0 deletions test/integration/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ def test_multiple_inventories(project_fixtures):
assert 'host_2' in stdout


def test_default_project_dir(project_fixtures):
private_data_dir = project_fixtures / 'project_dir_test'

res = run(
private_data_dir=private_data_dir,
playbook='debug.yml',
)
stdout = res.stdout.read()

assert res.rc == 0, stdout
assert 'project' in stdout


def test_project_dir(project_fixtures):
private_data_dir = project_fixtures / 'project_dir_test'

Expand All @@ -204,6 +217,41 @@ def test_project_dir(project_fixtures):
assert 'my_project' in stdout


@pytest.mark.test_all_runtimes
def test_default_project_dir_inside_container(project_fixtures, runtime):
private_data_dir = project_fixtures / 'project_dir_test'

res = run(
private_data_dir=private_data_dir,
playbook='debug.yml',
process_isolation_executable=runtime,
process_isolation=True,
container_image=defaults.default_container_image,
)
stdout = res.stdout.read()

assert res.rc == 0, stdout
assert 'project' in stdout


@pytest.mark.test_all_runtimes
def test_project_dir_inside_container(project_fixtures, runtime):
private_data_dir = project_fixtures / 'project_dir_test'

res = run(
private_data_dir=private_data_dir,
container_workdir='/runner/my_project',
playbook='debug.yml',
process_isolation_executable=runtime,
process_isolation=True,
container_image=defaults.default_container_image,
)
stdout = res.stdout.read()

assert res.rc == 0, stdout
assert 'my_project' in stdout


def test_inventory_absolute_path(project_fixtures):
private_data_dir = project_fixtures / 'debug'

Expand Down

0 comments on commit dc425f3

Please sign in to comment.