Update roles/pfsense_upgrade/tasks/upgrade.yml

This commit is contained in:
2026-04-30 15:42:58 -07:00
parent 07528451f0
commit 2fb407e404

View File

@@ -34,36 +34,29 @@
- name: Switch repository and force synchronization (GUI Native) - name: Switch repository and force synchronization (GUI Native)
ansible.builtin.raw: | ansible.builtin.raw: |
php -r ' nohup php -r '
require_once("/etc/inc/guiconfig.inc"); require_once("/etc/inc/guiconfig.inc");
require_once("/etc/inc/pkg-utils.inc"); require_once("/etc/inc/pkg-utils.inc");
global $g; global $g;
$target_repo = "{{ upgrade_target_repo }}"; $target_repo = "{{ upgrade_target_repo }}";
$repos = pkg_list_repos(); $repos = pkg_list_repos();
$found = false;
foreach ($repos as $repo) { foreach ($repos as $repo) {
if ($repo["name"] == $target_repo) { if ($repo["name"] == $target_repo) {
// Update XML config
config_set_path("system/pkg_repo_conf_path", $repo["path"]); config_set_path("system/pkg_repo_conf_path", $repo["path"]);
// Explicitly pull the path from the global array to ensure it is not null
$base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos"; $base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos";
// Force the physical symlink switch
pkg_switch_repo($base_path, $repo["name"]); pkg_switch_repo($base_path, $repo["name"]);
write_config("Branch switched to " . $repo["name"] . " via Ansible"); write_config("Branch switched to " . $repo["name"] . " via Ansible");
update_repos(); update_repos();
echo "Successfully switched to " . $repo["name"];
$found = true;
break; break;
} }
} }
if (!$found) { echo "ERROR: Repository not found"; exit(1); } ' > /dev/null 2>&1 &
' ignore_unreachable: true
register: _repo_switch when: perform_upgrade | bool
timeout: "{{ upgrade_check_timeout | default(120) }}"
changed_when: "'Successfully switched' in _repo_switch.stdout" - name: Wait for system to settle after repo switch
ansible.builtin.pause:
seconds: 10
when: perform_upgrade | bool when: perform_upgrade | bool
- name: Apply repository configuration via pfSense-repo-setup - name: Apply repository configuration via pfSense-repo-setup