Try symlink to upgrade
This commit is contained in:
@@ -32,26 +32,43 @@
|
||||
# changed_when: true
|
||||
# when: perform_upgrade | bool
|
||||
|
||||
- name: Switch repository and force synchronization (GUI Native)
|
||||
# - name: Switch repository and force synchronization (GUI Native)
|
||||
# ansible.builtin.raw: |
|
||||
# nohup php -r '
|
||||
# require_once("/etc/inc/guiconfig.inc");
|
||||
# require_once("/etc/inc/pkg-utils.inc");
|
||||
# global $g;
|
||||
# $target_repo = "{{ upgrade_target_repo }}";
|
||||
# $repos = pkg_list_repos();
|
||||
# foreach ($repos as $repo) {
|
||||
# if ($repo["name"] == $target_repo) {
|
||||
# config_set_path("system/pkg_repo_conf_path", $repo["path"]);
|
||||
# $base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos";
|
||||
# pkg_switch_repo($base_path, $repo["name"]);
|
||||
# write_config("Branch switched to " . $repo["name"] . " via Ansible");
|
||||
# update_repos();
|
||||
# break;
|
||||
# }
|
||||
# }
|
||||
# ' > /dev/null 2>&1 &
|
||||
# ignore_unreachable: true
|
||||
# when: perform_upgrade | bool
|
||||
|
||||
- name: Switch repository and force synchronization (Brute Force)
|
||||
ansible.builtin.raw: |
|
||||
nohup php -r '
|
||||
require_once("/etc/inc/guiconfig.inc");
|
||||
require_once("/etc/inc/pkg-utils.inc");
|
||||
global $g;
|
||||
$target_repo = "{{ upgrade_target_repo }}";
|
||||
$repos = pkg_list_repos();
|
||||
foreach ($repos as $repo) {
|
||||
if ($repo["name"] == $target_repo) {
|
||||
config_set_path("system/pkg_repo_conf_path", $repo["path"]);
|
||||
$base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos";
|
||||
pkg_switch_repo($base_path, $repo["name"]);
|
||||
write_config("Branch switched to " . $repo["name"] . " via Ansible");
|
||||
update_repos();
|
||||
break;
|
||||
}
|
||||
}
|
||||
' > /dev/null 2>&1 &
|
||||
ignore_unreachable: true
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user