-
Notifications
You must be signed in to change notification settings - Fork 54
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 |
I recently ran into the same thing using the following version of
And
and
Although even the above didn't help and I had so just replace the
After that the interface change was applied. I was just using the following ansible task:
And just a note, I was changing an existing interface not creating a new one. |
@elatov could you post the full traceback that you get without your fix? Also, could you save this to vlan.php on the pfsense box and send the output of
|
@opoplawski here is output of the command (the
When you say full traceback, do you mean from ansible, by running: |
From ansible as you describe, though with your output above it may not be necessary. What do you get running the php code if you remove the echo statement? The second foreach loop? Everything but the require_once? |
Just for the record, I don't get the leading |
I think I finally figured out what's going, I removed everything but the
I then looked at that file and I see a lot more
after playing around with the files, I noticed that some files do an
And it looks like it's when it's checking if the platform is booting:
Looking for that function I found it under
It looks for the presence of a file called
After removing that empty file:
The command doesn't show the
Honestly not sure why that leftover file is there. |
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: