diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73101012..684a5e9c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,4 +21,6 @@ jobs: - name: Copy ansible config run: cp ansible.cfg.template ansible.cfg - name: Run task test-localhost - run: ./task test-localhost \ No newline at end of file + run: ./task test-localhost + - name: Run task test-scripts + run: ./task test-scripts \ No newline at end of file diff --git a/roles/cron/files/cron-job-list b/roles/cron/files/cron-job-list index 2d1336ee..0b12a4a3 100755 --- a/roles/cron/files/cron-job-list +++ b/roles/cron/files/cron-job-list @@ -47,4 +47,4 @@ done : ${CRONTAB_USERNAME:="$USERNAME"} # Fetch and list the Ansible jobs from the crontab -sudo crontab -u "$CRONTAB_USERNAME" -l | grep '^#Ansible: ' | sed 's/^#Ansible: //' \ No newline at end of file +sudo crontab -u "$CRONTAB_USERNAME" -l | awk '/^#Ansible: / {getline nextline; print $1, $2, $3, $4, $5}' \ No newline at end of file diff --git a/roles/matomo/tasks/matomo.yml b/roles/matomo/tasks/matomo.yml index e2a0155a..2fadd89e 100644 --- a/roles/matomo/tasks/matomo.yml +++ b/roles/matomo/tasks/matomo.yml @@ -34,5 +34,5 @@ - name: Cron job to run {{ role_name }} background jobs ansible.builtin.cron: name: Run {{ role_name }} background jobs - minute: "*/5" + minute: "5" job: docker exec -u root {{ matomo_hostname }} bash -c "/usr/local/bin/php /var/www/html/console core:archive --url={{ matomo_url }} > /var/log/matomo-archive.log" diff --git a/task b/task index beee5c24..6a6b694a 100755 --- a/task +++ b/task @@ -19,20 +19,20 @@ function help() { printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "install" "" "Install Ansible and dependencies with uv." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "install-exo" "" "Install Exoscale CLI." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "upgrade" "" "Upgrade Ansible and dependencies with uv." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "llm-update" "[path][prompt]" "Feed role files with prompt to LLM and apply file changes." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "update-with-llm" "[path][prompt]" "Feed role files with prompt to LLM and apply file changes." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "lint" "" "Lint Ansible roles and playbooks." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "galaxy-build" "" "Create tarball of collection." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "galaxy-publish" "" "Publish tarball to Ansible Galaxy." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "node-install" "" "Install build dependencies." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "node-dev" "" "Start vuepress development server." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "node-build" "" "Create vuepress build." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "node-serve-build" "" "Serve vuepress build." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "build-galaxy" "" "Create tarball of collection." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "publish-galaxy" "" "Publish tarball to Ansible Galaxy." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "install-node" "" "Install build dependencies." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "dev-node" "" "Start vuepress development server." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "build-node" "" "Create vuepress build." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "serve-node-build" "" "Serve vuepress build." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "list-hosts" "[path]" "Lists all hosts of an inventory." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "version" "" "Show tool versions." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "source" "" "Source the Python virtual env." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "test-localhost" "[clean]" "Deploy to localhost. Pass option 'clean' to clean up." + printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "test-scripts" "" "Install and test scripts." printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "show-passwordless-sudo" "[username]" "Give instructions to setup passwordless sudo." - printf "| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n" "llm-update" "[path]" "Feed role files with prompt to LLM and apply updates with git path." echo } @@ -45,6 +45,8 @@ if [[ -a ".env" ]]; then export $(cat .env | sed 's/^#.*//g' | xargs) fi +# Ansible Vault commands + function generate-vault-password() { if test -z "$1"; then echo "\$1 is empty"; exit; fi if test -z "$2"; then echo "\$1 is empty"; exit; fi @@ -134,6 +136,7 @@ show-vault-file() { rm -f "$TEMP_PART_FILE" } +# Environment commands function init-venv() { if [ ! -d "venv$GIT_BRANCH" ]; then @@ -165,11 +168,26 @@ function install-exo() { curl -fsSL https://raw.githubusercontent.com/exoscale/cli/master/install-latest.sh | sh } +function version() { + activate-venv + uv --version + ansible --version +} + +function show-passwordless-sudo() { + USER=${1:-"$USERNAME"} + echo "echo \"$USER ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers" +} + +# Ansible commands + function upgrade() { echo "Update Ansible" uv pip install --upgrade ansible } +# Ansible Invenotry commands + function list-hosts() { if test -z "$1"; then echo "\$1 is empty"; exit; fi @@ -177,18 +195,9 @@ function list-hosts() { ansible -i $1 all --list-hosts } -function version() { - activate-venv - uv --version - ansible --version -} +# Ansible Galaxy commands -function show-passwordless-sudo() { - USER=${1:-"$USERNAME"} - echo "echo \"$USER ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers" -} - -function galaxy-build() { +function build-galaxy() { activate-venv VERSION=$(yq eval '.version' galaxy.yml) NAMESPACE=$(yq eval '.namespace' galaxy.yml) @@ -198,7 +207,7 @@ function galaxy-build() { mv $NAMESPACE-$NAME-$VERSION.tar.gz tmp/ } -function galaxy-publish() { +function publish-galaxy() { activate-venv VERSION=$(yq eval '.version' galaxy.yml) NAMESPACE=$(yq eval '.namespace' galaxy.yml) @@ -207,6 +216,8 @@ function galaxy-publish() { ansible-galaxy collection publish tmp/$NAMESPACE-$NAME-$VERSION.tar.gz --token "$GALAXY_API_TOKEN" } +# Test commands + function test-localhost() { activate-venv version @@ -229,9 +240,13 @@ function test-localhost() { fi } +function test-scripts() { + echo "Install cron scripts" +} + # LLM Commands -function llm-update() { +function update-with-llm() { if test -z "$1"; then echo "\$1 is empty."; exit 1; @@ -320,16 +335,16 @@ else help task exit 1 ;; - node-install) + install-node) npm install ;; - node-dev) + dev-node) npm run dev ;; - node-build) + build-node) npm run build ;; - node-serve-build) + serve-node-build) cd .vuepress/dist npx serve ;;