split logic for older system test

This commit is contained in:
2026-04-30 16:34:59 -07:00
parent c63387b8f6
commit 7598264700

View File

@@ -54,22 +54,55 @@
# ignore_unreachable: true # ignore_unreachable: true
# when: perform_upgrade | bool # when: perform_upgrade | bool
- name: Switch repository and force synchronization (Brute Force) # - 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
# pfSense-upgrade -d -y
# when: perform_upgrade | bool
- name: Repair Legacy Repo Structure (23.09.1/4200 Bug)
ansible.builtin.raw: | ansible.builtin.raw: |
# 1. Update the XML via PHP if [ -d /usr/local/share/pfSense/pkg/repos/ ]; then
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 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 mv /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf.bak 2>/dev/null || true
fi fi
fi
when: perform_upgrade | bool
# 3. Create the symlink to the new target - name: Switch Repository and Force Synchronization (GUI Method)
ln -sf /usr/local/etc/pfSense/pkg/repos/pfSense-repo-{{ upgrade_target_repo }}.conf /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf ansible.builtin.raw: |
php -r '
# 4. Force metadata refresh require_once("guiconfig.inc");
# pkg update -f require_once("pkg-utils.inc");
pfSense-upgrade -d -y $target = "{{ upgrade_target_repo }}";
$repos = pkg_list_repos();
foreach ($repos as $repo) {
if ($repo["name"] == $target) {
config_set_path("system/pkg_repo_conf_path", $repo["path"]);
if (function_exists("pkg_switch_repo")) {
pkg_switch_repo(g_get("pkg_repos_path"), $repo["name"]);
}
write_config("Repo switch to $target via Ansible");
update_repos();
echo "Successfully switched to " . $repo["name"];
break;
}
}
'
register: _repo_switch
changed_when: "'Successfully switched' in _repo_switch.stdout"
when: perform_upgrade | bool when: perform_upgrade | bool
- name: Wait for system to settle after repo switch - name: Wait for system to settle after repo switch