Skip to content

Commit a936b3e

Browse files
authored
Workaround for issues with phpIPAM 1.7.0 and above (#132)
For phpIPAM version 1.7.0 and above we need to set `api_stringify_results` to `true` to get stringified results from API. * Update test environment setup * Updated README with workaround for phpIPAM v1.7 and above
1 parent 14927d8 commit a936b3e

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ install-deps:
9393

9494
setup-phpipam: test-setup
9595
docker-compose -f tests/docker/docker-compose.yml up -d
96-
sh tests/docker/setup_database.sh
96+
sh tests/docker/setup_phpipam.sh
9797

9898
FORCE:
9999

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ The following dependencies have to be fulfiled by the Ansible controller.
5151
* ipaddress
5252
* phpypam>=1.0.0
5353

54+
## Compatibility notice
55+
56+
To ensure `phpipam-ansible-modules` work correctly with phpIPAM versions 1.7 and above, you need to modify the phpIPAM configuration to stringify API results. This is crucial because newer phpIPAM versions might return numerical values directly, which the Ansible modules might expect as strings.
57+
58+
Here's how to implement the workaround:
59+
60+
**1. Modify phpIPAM Configuration**
61+
62+
You need to set the `api_stringify_results` variable to `true` in your phpIPAM configuration. This change should be made in the `config.php` file, which is typically located in the phpIPAM installation directory (e.g., `/var/www/html/phpipam/config.php` or `/var/www/phpipam/config.php`).
63+
64+
Add or modify the following line in your `config.php` file:
65+
66+
```
67+
<?php
68+
/*
69+
* phpIPAM config.php
70+
*
71+
* ... existing configuration ...
72+
*/
73+
74+
// Required for Ansible modules with phpIPAM v1.7 and above
75+
$api_stringify_results = true;
76+
77+
/*
78+
* ... rest of your configuration ...
79+
*/
80+
?>
81+
```
5482
## Need help?
5583

5684
If you’ve found any issues in this release please head over to github and open a bug so we can take a look.

tests/docker/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '3'
21
services:
32
phpipam:
43
image: "phpipam/phpipam-www:${PHPIPAM_VERSION:-v1.4.4}"

tests/docker/setup_database.sh renamed to tests/docker/setup_phpipam.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ fi
1616

1717
if "${DOCKER_CMD}" ps | grep -q phpipam_test_webserver && ! eval "${MYSQL_PING}" ; then
1818

19+
if [[ $(echo "${PHPIPAM_VERSION:-v1.4.4}" | sed -E 's/v[0-9]?.([0-9]?).[0-9]?/\1/g') -ge 7 ]] ; then
20+
info "Running version 1.7.0 or above, patching config"
21+
${DOCKER_CMD} exec -t phpipam_test_webserver sh -c 'sed -i "s/api_stringify_results = false/api_stringify_results = true/g" /phpipam/config.dist.php'
22+
fi
23+
1924
info -n "Waiting for database connection "
2025
while ! eval "${MYSQL_PING}" ; do
2126
info -n "."
@@ -44,8 +49,8 @@ if [[ $(mysqlshow -u root -prootpw -h 127.0.0.1 -P 3306 phpipam 2>/dev/null | wc
4449

4550
else
4651

47-
info "Detabase already initiated" && exit 0
52+
info "Database already initiated" && exit 0
4853

4954
fi
5055

51-
info "Database initialisation $result"
56+
info "Database initialization $result"

0 commit comments

Comments
 (0)