d3vilh / openvpn-aws

OpenVPN and OpenVPN-UI for any Cloud or x86 bare metal instance
Apache License 2.0
103 stars 20 forks source link

When executing Ansible-Playbook, TASK: Restart monitoring issue #11

Closed Leeeuijooo closed 3 months ago

Leeeuijooo commented 3 months ago

Hello! d3vilh, who created a great program. It's a good day. I encounter An error occurred while provisioning main.yml.

Below is the error message that occurred when executing the configuration file and ansible-playbook.

config.yml

cat config.yml
---
# Location where configuration files will be stored.
config_dir: '~'

# OpenVPN configuration.
ovpn_enable: true

.
.
.
# OpenVPN monitoring configuration.             # Requires `monitoring_enable`
monitoring_enable: true                        # Set true to enable OpenVPN Server monitoring
monitoring_grafana_admin_password: "admin"      # Is only used the first time when Grafana starts up
monitoring_days_keep_interval: 90d              # How long to keep data in Prometheus DB (decrease if you have less than 5Gb of free disk space)

Error Message

# ansible-playbook main.yml -vvv
.
.
.

TASK [Restart monitoring (Ubuntu)] ********************************************************************************************************************************************************************************************************
task path: /var/snap/amazon-ssm-agent/7983/openvpn-aws/tasks/handlers_ubuntu.yml:10
<192.168.1.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.1.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<192.168.1.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1716532562.4734273-20691-168282374389484 `" && echo ansible-tmp-1716532562.4734273-20691-168282374389484="` echo /root/.ansible/tmp/ansible-tmp-1716532562.4734273-20691-168282374389484 `" ) && sleep 0'
Using module file /usr/local/lib/python3.10/dist-packages/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py
<192.168.1.1> PUT /root/.ansible/tmp/ansible-local-19664l8np24c6/tmps6sph3nn TO /root/.ansible/tmp/ansible-tmp-1716532562.4734273-20691-168282374389484/AnsiballZ_docker_compose_v2.py
<192.168.1.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1716532562.4734273-20691-168282374389484/ /root/.ansible/tmp/ansible-tmp-1716532562.4734273-20691-168282374389484/AnsiballZ_docker_compose_v2.py && sleep 0'
<192.168.1.1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1716532562.4734273-20691-168282374389484/AnsiballZ_docker_compose_v2.py && sleep 0'
<192.168.1.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1716532562.4734273-20691-168282374389484/ > /dev/null 2>&1 && sleep 0'
fatal: [openvpn-aws]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "api_version": "auto",
            "build": "never",
            "ca_path": null,
            "check_files_existing": true,
            "cli_context": null,
            "client_cert": null,
            "client_key": null,
            "definition": null,
            "dependencies": true,
            "docker_cli": null,
            "docker_host": "unix:///var/run/docker.sock",
            "env_files": null,
            "files": null,
            "profiles": null,
            "project_name": null,
            "project_src": "/root/monitoring/",
            "pull": "policy",
            "recreate": "auto",
            "remove_images": null,
            "remove_orphans": false,
            "remove_volumes": false,
            "scale": null,
            "services": null,
            "state": "restarted",
            "timeout": null,
            "tls": false,
            "tls_hostname": null,
            "validate_certs": false,
            "wait": false,
            "wait_timeout": null
        }
    },
    "msg": "\"/root/monitoring\" is not a directory"
}

PLAY RECAP ********************************************************************************************************************************************************************************************************************************
openvpn-aws                : ok=14   changed=1    unreachable=0    failed=1    skipped=22   rescued=0    ignored=0

I later determined that the error occurred because there was no directory called monitoring in the root directory, so I created the /root/monitoring directory.

But this time a different error message was displayed.

After Message

TASK [Restart monitoring (Ubuntu)] ********************************************************************************************************************************************************************************************************
task path: /var/snap/amazon-ssm-agent/7983/openvpn-aws/tasks/handlers_ubuntu.yml:10
<192.168.1.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.1.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<192.168.1.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1716532722.76547-21779-273806210835534 `" && echo ansible-tmp-1716532722.76547-21779-273806210835534="`echo /root/.ansible/tmp/ansible-tmp-1716532722.76547-21779-273806210835534 `" ) && sleep 0'
Using module file /usr/local/lib/python3.10/dist-packages/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py
<192.168.1.1> PUT /root/.ansible/tmp/ansible-local-20756qisf30ye/tmpwly8p6i7 TO /root/.ansible/tmp/ansible-tmp-1716532722.76547-21779-273806210835534/AnsiballZ_docker_compose_v2.py
<192.168.1.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1716532722.76547-21779-273806210835534/ /root/.ansible/tmp/ansible-tmp-1716532722.76547-21779-273806210835534/AnsiballZ_docker_compose_v2.py && sleep 0'
<192.168.1.1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1716532722.76547-21779-273806210835534/AnsiballZ_docker_compose_v2.py && sleep 0'
<192.168.1.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1716532722.76547-21779-273806210835534/ > /dev/null 2>&1 && sleep 0'
fatal: [openvpn-aws]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "api_version": "auto",
            "build": "never",
            "ca_path": null,
            "check_files_existing": true,
            "cli_context": null,
            "client_cert": null,
            "client_key": null,
            "definition": null,
            "dependencies": true,
            "docker_cli": null,
            "docker_host": "unix:///var/run/docker.sock",
            "env_files": null,
            "files": null,
            "profiles": null,
            "project_name": null,
            "project_src": "/root/monitoring/",
            "pull": "policy",
            "recreate": "auto",
            "remove_images": null,
            "remove_orphans": false,
            "remove_volumes": false,
            "scale": null,
            "services": null,
            "state": "restarted",
            "timeout": null,
            "tls": false,
            "tls_hostname": null,
            "validate_certs": false,
            "wait": false,
            "wait_timeout": null
        }
    },
    "msg": "\"/root/monitoring\" does not contain compose.yaml, compose.yml, docker-compose.yaml, or docker-compose.yml"
}

PLAY RECAP ********************************************************************************************************************************************************************************************************************************
openvpn-aws                : ok=14   changed=1    unreachable=0    failed=1    skipped=22   rescued=0    ignored=0

You can see a message that there are no files related to docker in the /root/monitoring directory.

Should I manually insert the openvpn_exporter-docker-compose.yml.j2 jinja template from the template directory into /root/monitoring/? Is there any way?

d3vilh commented 3 months ago

Hi @Leeeuijooo Thanks for the reporting. Monitoring at the moment does not supported, that is why you have this issue. I just plan it for future development.

It will be based on Grafana, Prometheus and my openvpn-exporter.

Please set monitoring_enable: false and run playbook again.