Attempt to update the repo switch to work with older versions.

This commit is contained in:
2026-04-30 14:59:47 -07:00
parent 40afb2ac7a
commit 37b911d834

View File

@@ -18,12 +18,44 @@
# ---------------------------------------------------------------------------
# 1. Switch repository in configuration
# ---------------------------------------------------------------------------
- name: Switch repository in config.xml
# - name: Switch repository in config.xml
# ansible.builtin.raw: |
# php -r '
# require_once("/etc/inc/config.inc");
# require_once("/etc/inc/pkg-utils.inc");
# config_set_path("system/pkg_repo_conf_path", "{{ upgrade_target_repo }}");
# write_config("Switched to {{ upgrade_target_repo }} for upgrade");'
# register: _repo_switch
# timeout: "{{ upgrade_check_timeout | default(120) }}"
# changed_when: true
# when: perform_upgrade | bool
- name: Switch repository and force synchronization (GUI Native)
ansible.builtin.raw: |
php -r 'require_once("/etc/inc/config.inc"); require_once("/etc/inc/pkg-utils.inc"); config_set_path("system/pkg_repo_conf_path", "{{ upgrade_target_repo }}"); write_config("Switched to {{ upgrade_target_repo }} for upgrade");'
php -r '
require_once("guiconfig.inc");
require_once("pkg-utils.inc");
$target_repo = "{{ upgrade_target_repo }}";
$repos = pkg_list_repos();
$found = false;
foreach ($repos as $repo) {
if ($repo["name"] == $target_repo || $repo["path"] == $target_repo) {
config_set_path("system/pkg_repo_conf_path", $repo["path"]);
pkg_switch_repo(g_get("pkg_repos_path"), $repo["name"]);
write_config("Branch switched to " . $repo["name"] . " via Ansible");
update_repos();
echo "Successfully switched to " . $repo["name"];
$found = true;
break;
}
}
if (!$found) { echo "ERROR: Repository not found"; exit(1); }
'
register: _repo_switch
timeout: "{{ upgrade_check_timeout | default(120) }}"
changed_when: true
changed_when: "'Successfully switched' in _repo_switch.stdout"
when: perform_upgrade | bool
- name: Apply repository configuration via pfSense-repo-setup
@@ -34,7 +66,14 @@
- name: Verify repository switch took effect
ansible.builtin.raw: |
php -r 'require_once("/etc/inc/pkg-utils.inc"); foreach(pkg_list_repos() as $r) { if (isset($r["default"])) { echo $r["name"]; } }'
php -r '
require_once("/etc/inc/pkg-utils.inc");
foreach(pkg_list_repos() as $r)
{
if (isset($r["default"])) {
echo $r["name"];
}
}'
register: _verify_repo_switch
when: perform_upgrade | bool