-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module_utils/pfsense.py:PFSenseModule.php JSONDecodeError: Expecting value: line 1 column 1 (char 0) #118
Comments
A reproducer would be nice, but I'll also note that anible 2.10 went EOL on 23 May 2022. How do you use openstack to deploy pfsense? |
I have an UbuntuJammy2204 VM setup on Openstack with internet access, running python 3.10.12 with ansible installed. I also have the python-openstackclient python module installed via pip. To deploy the pfsense VM I use this task. In an example environment I have two networks - name: "Create pfSense instance - {{ router.key }}_pfsense"
host: localhost
command: >
openstack server create
--flavor {{ router.value.flavor }}
--image {{ router.value.image }}
--boot-from-volume {{ router.value.image_size }}
--nic net-id={{ local_1.net_id }},v4-fixed-ip="192.168.1.1"
--nic net-id={{ remote_1.net_id }},v4-fixed-ip="10.0.1.1"
--key-name {{ ansible_control_key_name }}
{{ router.key }}_pfsense
ignore_errors: yes ansible_control_key_name is the name of ssh public key stored in openstack of the UbuntuJammy2204 VM I am running the ansible on to deploy the VMs from. team_1_main:
image: PFsense-2.6.0-Cloudinit
image_size: 40
flavor: medium
connections:
local_1:
address: 192.168.1.1
control: 192.168.1.250
remote_1:
address: 10.0.1.254 I then create an openstack port from the UbuntuJammy2204 VM to local_1 so I have access to one of the router's interfaces. This creates a new NIC interface on UbuntuJammy2204 VM, assigning it the control address on the local_1 network. Then with a very bare test config like: pfsenses:
team_1_main_pfsense: {
interfaces: {
WAN: { ip: 10.0.1.254/24 },
LAN: { ip: 192.168.1.1/24 }
}
}
rules:
options: { log: yes }
ALLOW_ALL:
allow_all: { src: any, dst: any, protocol: any, action: pass }
hosts_aliases:
internet: { ip: 0.0.0.0/0 }
ports_aliases:
admin_ports: { port: 22 80 443 } running the examples/lookup/setup_all_rules.yaml playbook to setup firewall rules is where the fatal error occurs. my inventory.ini being: [pfsense]
team_1_main_pfsense ansible_ssh_host=192.168.1.1
[pfsense:vars]
ansible_ssh_user=admin
ansible_ssh_password=pfsense
ansible_ssh_port=22
ansible_ssh_common_args='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
ansible_python_interpreter=/usr/local/bin/python3.8 and ansible.cfg being: [defaults]
inventory = ./inventory.ini
collections_paths = ./collections/ The php that is run that causes the error is: <?php
require_once("/etc/inc/interfaces.inc");
$portlist = get_interface_list();
$lagglist = get_lagg_interface_list();
$portlist = array_merge($portlist, $lagglist);
foreach ($lagglist as $laggif => $lagg) {
$laggmembers = explode(',', $lagg['members']);
foreach ($laggmembers as $lagm)
if (isset($portlist[$lagm])) unset($portlist[$lagm]);
}
$list = array();
foreach ($portlist as $ifn => $ifinfo) {
$list[$ifn] = $ifn . " (\" . $ifinfo[\"mac\"] . \")";
$iface = convert_real_interface_to_friendly_interface_name($ifn);
if (isset($iface) && strlen($iface) > 0) $list[$ifn] .= " - $iface";
}
echo json_encode($list);
?> stdout is
stderr is (sorry for formatting)
|
here is
|
I think there has to be something strange about your setup - which is unusual and making use of old versions of ansible and pfsense. I can't reproduce it with pfSense 2.6.0. I'd be open to some validation of the output returned, but not all valid JSON starts and ends with braces, so your proposed solution doesn't look correct to me. |
That's fair. My initial solution breaks other modules that use the php function where the returned json doesn't start and end with |
Using openstack and ansible 2.10.8 to deploy and configure some pfsense 2.6.0 instances. It seems
self.module.run_command('/usr/local/bin/php', data=cmd)
has..
added to the beginning of stdout causing JSONDecoder to throw an error when trying to parse the returned json string from php. I fixed this by changing the php function to the following.The text was updated successfully, but these errors were encountered: