# Best way to update this service (Matrix Ansible)

**URL:** <https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [May 3, 2024, 6:17am UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276 "2024-05-03T06:17:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://forum.ansible.com/u/corin.corvus)\
**Post date:** [May 3, 2024, 6:17am UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/1 "2024-05-03T06:17:29Z")

</div>

Hi,

i’m a newbie in ansible. I work with the ansible playbook of spantaleev for the matrix docker ansible deploy and at the moment i finished some automations for updating or installing vms or container in my homelab with my own gitlab and Ansible Semaphore.

Yesterday i tried to integrate my matrix server, but i struggle with the correct way to do this.

Status:  
At the moment i have the vm and on the vm is the playbook [GitHub - spantaleev/matrix-docker-ansible-deploy: 🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker](https://github.com/spantaleev/matrix-docker-ansible-deploy)

For example to update the matrix server i need to execute following commands:

- git pull
- just roles
- ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start

Now i want to migrate this steps in my semaphore and i tried to build some playbooks to execute this commands, but never it works.

First i tried to create a playbook to execute the commands on the remote host.

```auto
---
- name: Git-Pull, Rollen ausführen, und Setup mit Tags
  hosts: matrix
  become: yes
  tasks:
    - name: Git-Repository aktualisieren
      git:
        repo: 'https://github.com/spantaleev/matrix-docker-ansible-deploy'
        dest: '/opt/matrix-docker-ansible-deploy'
        update: yes
        force: yes # Optional, erzwingt das Update, auch wenn es lokale Änderungen gibt

    - name: Ansible-Rollen ausführen
      command: 'just roles'
      args:
        chdir: '/opt/matrix-docker-ansible-deploy' # Das Verzeichnis, in dem der Befehl ausgeführt wird

    - name: Ansible-Setup-Playbook mit Tags ausführen
      command: 'ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start' # Playbook mit Tags ausführen
      args:
        chdir: '/opt/matrix-docker-ansible-deploy' # Das Verzeichnis, in dem der Befehl ausgeführt wird

```

but the commands failed with “just not found”

```auto
fatal: [matrix]: FAILED! => {"changed": false, "cmd": "ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start", "msg": "[Errno 2] Datei oder Verzeichnis nicht gefunden: b'ansible-playbook'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

```

i also tried with shell instead of command and env “shell path”. It also failed.

```auto
- name: Ansible-Rollen ausführen
  shell: "/usr/bin/just roles"
  args:
    chdir: '/opt/matrix-docker-ansible-deploy'
  environment:
    SHELL: "/bin/bash" # Wechseln Sie zu bash, falls /bin/sh Probleme bereitet
    PATH: "/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin" # PATH sicherstellen

```

so i tried another way. Chatgpt recommended me, i can pull the repo and push it in my gitlab to use it. I did solve the pull and push, and could automate this, but i dont know, how i can use it useful. i prefer an easier way.

Note: in the playbook for matrix i need to use a vars.yaml in Inventory:

> <https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/configuring-playbook.md>

Maybe anyone here can explain me, how i can solve this easier. I think i stuck in my minds.

Thanks

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [May 3, 2024, 10:16am UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/2 "2024-05-03T10:16:31Z")

</div>

> [@corin.corvus](#):
>
> the commands failed with “just not found”

[just is a prerequisite](https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/0b7910fc090235b25f24e0782fbd45f482e2a109/docs/prerequisites.md?plain=1#L29), you will need to install it before you can use it.

> **[GitHub - casey/just: 🤖 Just a command runner](https://github.com/casey/just?tab=readme-ov-file#just)**
>
> 🤖 Just a command runner

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://forum.ansible.com/u/corin.corvus)\
**Post date:** [May 3, 2024, 11:34am UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/3 "2024-05-03T11:34:29Z")

</div>

its installed on both (ansible semaphore server and matrix server)  
On the Matrix Server i used it before locally

i wrote it at the beginning:

 ![brave_UPowY4LXx3](https://us1.discourse-cdn.com/ansible/original/2X/1/1c957c639602ff2ae2637d01c9f6bd710803bc25.jpeg)

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [May 3, 2024, 11:35am UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/4 "2024-05-03T11:35:16Z")

</div>

What does this return:

```bash
ls -lah /usr/bin/just

```

And:

```bash
which just

```

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://forum.ansible.com/u/corin.corvus)\
**Post date:** [May 3, 2024, 11:39am UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/5 "2024-05-03T11:39:55Z")

</div>

in the ansible semaphore container i cant use this commands.

on matrix  
root@matrix:~# ls -lah /usr/bin/just  
-rwxr-xr-x 1 root root 3.5M Mar 12 05:47 /usr/bin/just  
root@matrix:~# which just  
/usr/bin/just  
root@matrix:~#

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [May 3, 2024, 11:57am UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/6 "2024-05-03T11:57:43Z")

</div>

It’s odd that using the CLI you have `just` but Ansible doesn’t see it, perhaps add a check for it before trying to run it?

```yaml
    - name: Check just
      ansible.builtin.stat:
        path: /usr/bin/just
      register: just_path 

    - name: Just is required
      ansible.builtin.assert:
        that:
           - just_path.stat.exists | bool
        fail_msg: "The check for /usr/bin/just failed."

    - name: Ansible-Rollen ausführen
      command: 'just roles'
      args:
        chdir: '/opt/matrix-docker-ansible-deploy' # Das Verzeichnis, in dem der Befehl ausgeführt wird

```

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://forum.ansible.com/u/corin.corvus)\
**Post date:** [May 3, 2024, 12:39pm UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/7 "2024-05-03T12:39:53Z")

</div>

if i can completely use another way i would prefer it.

Today morning i test a new playbook for direct using the github playbook and use just in the container of ansible semaphore.

i came a good way forward.  
I add the vars.yml of my old playbook into the inventory of my new ansible installation. After i added “just” to my requirements and its installed.

At the moment i get this error:

```auto
1:38:51 PM
Task 287 added to queue
1:38:53 PM
Started: 287
1:38:53 PM
Run TaskRunner with template: Matrix - Update Playbook
1:38:54 PM
Preparing: 287
1:38:54 PM
Updating Repository https://github.com/spantaleev/matrix-docker-ansible-deploy
1:38:55 PM
ERROR! the role 'galaxy/playbook_help' was not found in /tmp/semaphore/repository_3_15/roles:/tmp/semaphore/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/semaphore/repository_3_15
1:38:55 PM
      ^ here
1:38:55 PM
    - role: galaxy/playbook_help
1:38:55 PM
    # Most of the roles below are not distributed with the playbook, but downloaded separately using `ansible-galaxy` via the `just roles` command (see `justfile`).
1:38:55 PM
1:38:55 PM
The offending line appears to be:
1:38:55 PM
1:38:55 PM
be elsewhere in the file depending on the exact syntax problem.
1:38:55 PM
The error appears to be in '/tmp/semaphore/repository_3_15/setup.yml': line 8, column 7, but may
1:38:55 PM
1:38:55 PM
No roles/requirements.yml file found. Skip galaxy install process.
1:38:55 PM
collections/requirements.yml has no changes. Skip galaxy install process.
1:38:55 PM
installing static inventory
1:38:55 PM
Already up to date.
1:38:55 PM
 * branch master -> FETCH_HEAD
1:38:55 PM
From https://github.com/spantaleev/matrix-docker-ansible-deploy
1:38:56 PM
Running playbook failed: exit status 1

```

```auto
ERROR! the role 'galaxy/playbook_help' was not found in /tmp/semaphore/repository_3_15/roles:/tmp/semaphore/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/semaphore/repository_3_15

```

iam not sure, how i have to add the role.

in my old local installation “galaxy” is in “roles” in the repository.  
“/opt/matrix-docker-ansible-deploy/roles/galaxy”

in my ols installation i simply used “just roles”. I am not sure what i have to do in ansible semaphore to add the roles.

Thanks

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [May 3, 2024, 12:55pm UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/8 "2024-05-03T12:55:34Z")

</div>

The path for roles installed using `ansible-galaxy` can be set in a `ansible.cfg` file, for example:

```ini
[defaults]
roles_path = roles/galaxy

```

---

<div class="post-metadata">

**Author:** ![corin.corvus](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@corin.corvus](https://forum.ansible.com/u/corin.corvus)\
**Post date:** [May 3, 2024, 12:57pm UTC](https://forum.ansible.com/t/best-way-to-update-this-service-matrix-ansible/5276/9 "2024-05-03T12:57:30Z")

</div>

its not my repository. in this case i clone directly from [GitHub - spantaleev/matrix-docker-ansible-deploy: 🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker](https://github.com/spantaleev/matrix-docker-ansible-deploy).

But in the ansible.cfg the path not exist.

```auto
[defaults]
retry_files_enabled = False
stdout_callback = yaml

[connection]
pipelining = True

```
