diff --git a/justfile b/justfile index bfeabd3ab..db668f283 100644 --- a/justfile +++ b/justfile @@ -26,19 +26,27 @@ roles: @{{ just_executable() }} --justfile "{{ justfile() }}" _install-roles # Updates the playbook and installs the necessary Ansible roles pinned in requirements.yml. If a -u flag is passed, also updates the requirements.yml file with new role versions (if available) -update *flags: update-playbook-only +update *flags: #!/usr/bin/env sh set -eu - if [ "{{ flags }}" = "-u" ] && [ -x "$(command -v agru)" ]; then + if [ -n "{{ flags }}" ] && [ "{{ flags }}" != "-u" ]; then + echo "Unknown flags passed: {{ flags }}" >&2 + exit 1 + fi + if [ "{{ flags }}" = "-u" ] && ! [ -x "$(command -v agru)" ]; then + echo "Updating role versions (-u) requires the agru tool: https://github.com/etkecc/agru#where-to-get" >&2 + exit 1 + fi + + {{ just_executable() }} --justfile "{{ justfile() }}" update-playbook-only + + if [ "{{ flags }}" = "-u" ]; then # This updates the versions pinned in requirements.yml and installs the roles echo "Updating roles and pinning new versions in requirements.yml…" agru -p roles/galaxy/ -no-tui -u - exit 0 + else + {{ just_executable() }} --justfile "{{ justfile() }}" _install-roles fi - if [ -n "{{ flags }}" ]; then - echo "Ignoring unsupported flags: {{ flags }}" - fi - {{ just_executable() }} --justfile "{{ justfile() }}" _install-roles # Updates the playbook without installing/updating Ansible roles update-playbook-only: