Try symlink to upgrade
This commit is contained in:
@@ -32,26 +32,43 @@
|
|||||||
# 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: |
|
||||||
|
# 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: |
|
ansible.builtin.raw: |
|
||||||
nohup php -r '
|
# 1. Update the XML via PHP
|
||||||
require_once("/etc/inc/guiconfig.inc");
|
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");'
|
||||||
require_once("/etc/inc/pkg-utils.inc");
|
|
||||||
global $g;
|
# 2. If it is a real file and not a link, move it to a backup
|
||||||
$target_repo = "{{ upgrade_target_repo }}";
|
if [ ! -L /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf ]; then
|
||||||
$repos = pkg_list_repos();
|
mv /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf.bak
|
||||||
foreach ($repos as $repo) {
|
fi
|
||||||
if ($repo["name"] == $target_repo) {
|
|
||||||
config_set_path("system/pkg_repo_conf_path", $repo["path"]);
|
# 3. Create the symlink to the new target
|
||||||
$base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos";
|
ln -sf /usr/local/etc/pfSense/pkg/repos/pfSense-repo-{{ upgrade_target_repo }}.conf /usr/local/share/pfSense/pkg/repos/pfSense-repo.conf
|
||||||
pkg_switch_repo($base_path, $repo["name"]);
|
|
||||||
write_config("Branch switched to " . $repo["name"] . " via Ansible");
|
# 4. Force metadata refresh
|
||||||
update_repos();
|
pkg update -f
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
' > /dev/null 2>&1 &
|
|
||||||
ignore_unreachable: true
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user