From 202a3ad5feac7c8ddc032ed13b0a4122a0a0414a Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Tue, 13 Feb 2024 17:17:02 -0300 Subject: [PATCH] Pass --file when running juju model-defaults Juju>=3.0 added the `--file` flag when passing the default values for a model in a yaml file. This change checks the juju client's version using `dpkg --compare-versions`. --- roles/juju-setup/tasks/main.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/juju-setup/tasks/main.yaml b/roles/juju-setup/tasks/main.yaml index ebe3709..d1f7f6c 100644 --- a/roles/juju-setup/tasks/main.yaml +++ b/roles/juju-setup/tasks/main.yaml @@ -105,6 +105,11 @@ - systemctl daemon-reload - systemctl restart systemd-resolved EOF - /snap/bin/juju model-default /home/ubuntu/cloudinit-userdata.yaml + # juju>=3.0 expects the `--file` flag to pass default values in a file. + if dpkg --compare-versions $(juju --version | cut -d- -f1) ge 3.0.0; then + /snap/bin/juju model-defaults --file /home/ubuntu/cloudinit-userdata.yaml + else + /snap/bin/juju model-defaults /home/ubuntu/cloudinit-userdata.yaml + fi args: executable: /bin/bash