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,24 +54,57 @@
# 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: | # ansible.builtin.raw: |
# 1. Update the XML via PHP # # 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");' # 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 # # 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
fi # fi
# 3. Create the symlink to the new target # # 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 # 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 # # 4. Force metadata refresh
# pkg update -f # # pkg update -f
pfSense-upgrade -d -y # pfSense-upgrade -d -y
when: perform_upgrade | bool # when: perform_upgrade | bool
- name: Repair Legacy Repo Structure (23.09.1/4200 Bug)
ansible.builtin.raw: |
if [ -d /usr/local/share/pfSense/pkg/repos/ ]; 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 2>/dev/null || true
fi
fi
when: perform_upgrade | bool
- name: Switch Repository and Force Synchronization (GUI Method)
ansible.builtin.raw: |
php -r '
require_once("guiconfig.inc");
require_once("pkg-utils.inc");
$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
- 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