From b05429b62f3ed34068b8ae49db77369d0df4186e Mon Sep 17 00:00:00 2001 From: Steven Hodges Date: Fri, 10 Jan 2025 12:17:26 -0600 Subject: [PATCH 1/5] Fix typos Fix typos in `address` and `section` module. Typo in `section` module could have functional impact. --- docs/plugins/address_module.rst | 2 +- plugins/modules/section.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/plugins/address_module.rst b/docs/plugins/address_module.rst index d10f9e4..89ef2e7 100644 --- a/docs/plugins/address_module.rst +++ b/docs/plugins/address_module.rst @@ -348,7 +348,7 @@ Parameters
- IP address to hanle + IP address to handle .. raw:: html diff --git a/plugins/modules/section.py b/plugins/modules/section.py index 4f3b6c1..954c665 100644 --- a/plugins/modules/section.py +++ b/plugins/modules/section.py @@ -122,7 +122,7 @@ def main(): phpipam_spec=dict( name=dict(type='str', required=True), description=dict(type='str', required=False), - parent=dict(type='entity', controller='sections', required=False, defautl=None, phpipam_name='masterSection'), + parent=dict(type='entity', controller='sections', required=False, default=None, phpipam_name='masterSection'), permissions=dict(type='json', required=False, default=None), strict_mode=dict(type='bool', required=False), subnet_ordering=dict(type='bool', required=False, phpipam_name='subnetOrdering'), From 51d4cb0cee3a4c908446f5baa77baf67a348f9eb Mon Sep 17 00:00:00 2001 From: Steven Hodges Date: Fri, 10 Jan 2025 12:18:15 -0600 Subject: [PATCH 2/5] Set default for `app_id` as mentioned in docs Update `app_id` to be not required and set default to ansible as per documentation. --- plugins/module_utils/phpipam_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/phpipam_helper.py b/plugins/module_utils/phpipam_helper.py index 780db23..e7aa6e9 100644 --- a/plugins/module_utils/phpipam_helper.py +++ b/plugins/module_utils/phpipam_helper.py @@ -58,7 +58,7 @@ def __init__(self, **kwargs): self.phpipam_spec, gen_args = self._phpipam_spec_helper(kwargs.pop('phpipam_spec', {})) argument_spec = dict( server_url=dict(required=True, fallback=(env_fallback, ['PHPIPAM_SERVER_URL'])), - app_id=dict(required=True, fallback=(env_fallback, ['PHPIPAM_APP_ID'])), + app_id=dict(required=False, fallback=(env_fallback, ['PHPIPAM_APP_ID']), default='ansible'), username=dict(required=True, fallback=(env_fallback, ['PHPIPAM_USERNAME'])), password=dict(required=True, fallback=(env_fallback, ['PHPIPAM_PASSWORD']), no_log=True), validate_certs=dict(type='bool', fallback=(env_fallback, ['PHPIPAM_VALIDATE_CERTS']), required=False, default=True), From 5beac6b4d6d4742a22cc20a64505d0d1a3cee193 Mon Sep 17 00:00:00 2001 From: Steven Hodges Date: Wed, 15 Jan 2025 09:52:30 -0600 Subject: [PATCH 3/5] New test to ensure app_id deafults to 'ansible' test --- tests/test_playbooks/shared_vars.yml | 19 +++++++++++++++++++ .../tasks/shared_vars_section.yml | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/test_playbooks/shared_vars.yml create mode 100644 tests/test_playbooks/tasks/shared_vars_section.yml diff --git a/tests/test_playbooks/shared_vars.yml b/tests/test_playbooks/shared_vars.yml new file mode 100644 index 0000000..6b36459 --- /dev/null +++ b/tests/test_playbooks/shared_vars.yml @@ -0,0 +1,19 @@ +- name: Check app_id defaults to 'ansible' + hosts: localhost + gather_facts: false + vars_files: + - vars/server.yml + - vars/section.yml + tasks: + - name: Create section + ansible.builtin.include_tasks: tasks/shared_vars_section.yml + vars: + step: create section + section: '{{ base_section_data }}' + - name: Delete section + ansible.builtin.include_tasks: tasks/shared_vars_section.yml + vars: + step: delete section + override: + state: absent + section: '{{ base_section_data | combine(override) }}' diff --git a/tests/test_playbooks/tasks/shared_vars_section.yml b/tests/test_playbooks/tasks/shared_vars_section.yml new file mode 100644 index 0000000..3c69c76 --- /dev/null +++ b/tests/test_playbooks/tasks/shared_vars_section.yml @@ -0,0 +1,19 @@ +--- +- name: "Ensure state of section: {{ step }}" + codeaffen.phpipam.section: + server_url: "{{ phpipam_server_url }}" + username: "{{ phpipam_username }}" + password: "{{ phpipam_password }}" + name: "{{ section.name }}" + description: "{{ section.description | default(omit) }}" + parent: "{{ section.parent | default(omit) }}" + permissions: "{{ section.permissions | default(omit) }}" + strict_mode: "{{ section.strict_mode | default(omit) }}" + subnet_ordering: "{{ section.subnet_ordering | default(omit) }}" + list_order: "{{ section.list_order | default(omit) }}" + show_vlan: "{{ section.show_vlan | default(omit) }}" + show_vrf: "{{ section.show_vrf | default(omit) }}" + show_supernets_only: "{{ section.show_supernets_only | default(omit) }}" + dns_resolver: "{{ section.dns_resolver | default(omit) }}" + validate_certs: "{{ section.validate_certs | default('no') }}" + state: "{{ section.state | default('present') }}" From 17394160339e4f9901802c615ba94f6284d8036b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 3 Nov 2024 14:34:17 +0100 Subject: [PATCH 4/5] Fix test tool chain * make tool chain work with podman too * update db setup script to work with podman * set predictable container names * fix fissues with starting docker-compose in CI * upgrade `docker-compose` before run phpipam-action * pin python to version 3.9 as long we did not found time to test newer versions run stale workflow on hosted runners --- .github/workflows/main.yml | 4 +++- .github/workflows/stale.yml | 4 ++-- tests/docker/docker-compose.yml | 2 ++ tests/docker/setup_database.sh | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 23ea58f..95e411a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,8 @@ jobs: matrix: phpipam-version: ['v1.4x', 'v1.5x'] steps: + - name: Upgrade docker-compose + run: sudo apt-get install --upgrade docker-compose - uses: actions/checkout@v3 - name: setup phpipam uses: codeaffen/phpipam-action@v2 @@ -18,7 +20,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v3 with: - python-version: '3.x' + python-version: '3.9' - name: setup test environment run: | make test-setup diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 0f376d6..7b9f8d3 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -15,8 +15,8 @@ permissions: jobs: stale: - # runs-on: ubuntu-latest - runs-on: [self-hosted] + runs-on: ubuntu-latest + # runs-on: [self-hosted] steps: - uses: actions/stale@v8 with: diff --git a/tests/docker/docker-compose.yml b/tests/docker/docker-compose.yml index 92c7b89..2596560 100644 --- a/tests/docker/docker-compose.yml +++ b/tests/docker/docker-compose.yml @@ -11,6 +11,7 @@ services: IPAM_DATABASE_NAME: "phpipam" depends_on: - database + container_name: phpipam_test_webserver database: image: mariadb:10.3.18 ports: @@ -20,3 +21,4 @@ services: MYSQL_USER: "phpipam" MYSQL_PASSWORD: "phpipamadmin" MYSQL_DATABASE: "phpipam" + container_name: phpipam_test_db diff --git a/tests/docker/setup_database.sh b/tests/docker/setup_database.sh index 0ba763a..ffb2d03 100644 --- a/tests/docker/setup_database.sh +++ b/tests/docker/setup_database.sh @@ -1,6 +1,6 @@ #!/bin/bash -if grep -q podman <<< $(docker --version 2> /dev/null) ; then +if grep -iq podman <<< $(docker version 2> /dev/null) ; then echo "Podman is installed" DOCKER_CMD=$(which podman) fi @@ -13,7 +13,7 @@ done echo "Database is up" echo "Creating database ${DB_NAME:-phpipam}" -${DOCKER_CMD} exec -ti docker_phpipam_1 sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' +${DOCKER_CMD} exec -ti phpipam_test_webserver sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' echo "Activating API" mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE settings SET api=1 WHERE id=1;" From 63a7e489b17b0f0c9abb376d720fc198be4c4cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 12 Jan 2025 11:24:57 +0100 Subject: [PATCH 5/5] Fix issues with starting docker-compose in CI (#125) * upgrade `docker-compose` before run phpipam-action * pin python to version 3.9 as long we did not found time to test newer versions