Try symlink to upgrade

This commit is contained in:
2026-04-30 16:08:08 -07:00
parent 2fb407e404
commit 166e0d8f36

View File

@@ -32,28 +32,45 @@
# changed_when: true # changed_when: true
# when: perform_upgrade | bool # when: perform_upgrade | bool
- name: Switch repository and force synchronization (GUI Native) # - name: Switch repository and force synchronization (GUI Native)
ansible.builtin.raw: | # ansible.builtin.raw: |
nohup 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();
foreach ($repos as $repo) { # foreach ($repos as $repo) {
if ($repo["name"] == $target_repo) { # if ($repo["name"] == $target_repo) {
config_set_path("system/pkg_repo_conf_path", $repo["path"]); # config_set_path("system/pkg_repo_conf_path", $repo["path"]);
$base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos"; # $base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos";
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();
break; # break;
} # }
} # }
' > /dev/null 2>&1 & # ' > /dev/null 2>&1 &
ignore_unreachable: true # ignore_unreachable: true
when: perform_upgrade | bool # when: perform_upgrade | bool
- name: Switch repository and force synchronization (Brute Force)
ansible.builtin.raw: |
# 1. Update the XML via PHP
php -r 'require_once("config.inc"); config_set_path("system/pkg_repo_conf_path", "/usr/local/etc/pfSense/pkg/repos/pfSense-repo-{{ upgrade_target_repo }}.conf"); write_config("Ansible repo switch");'
# 2. If it is a real file and not a link, move it to a backup
if [ ! -L /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf ]; then
mv /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf.bak
fi
# 3. Create the symlink to the new target
ln -sf /usr/local/etc/pfSense/pkg/repos/pfSense-repo-{{ upgrade_target_repo }}.conf /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf
# 4. Force metadata refresh
pkg update -f
when: perform_upgrade | bool
- name: Wait for system to settle after repo switch - name: Wait for system to settle after repo switch
ansible.builtin.pause: ansible.builtin.pause:
seconds: 10 seconds: 10