TOSIT-IO / tdp-lib

Python library to configure, manage and deploy TDP
Apache License 2.0
4 stars 8 forks source link

Transform run directory to current working directory (globally available `--cwd`) #612

Open PaulFarault opened 3 months ago

PaulFarault commented 3 months ago

Which issue(s) this PR fixes

Fixes #488

The --run-directory option is only applied to the the tdp deploy command. We should extend it's usage to the whole CLI so that other features can benefit from it.

In particular, inventory parsing does not work if tdp commands are launched from another location.

Additional comments

I needed to implement singleton pattern because of ansible strange way to initialize it's config (when importing a module, creating a class, etc.).

Agreements

SteBaum commented 3 months ago

When I try executing a deployment from another directory I have the following error:

(venv) sbaume-consultant01@M093-1309930:~/Documents/tdp/tdp-ops/tdp/tdp-lib$ tdp --env /home/sbaume-consultant01/Documents/tdp/tdp-ops/.env --cwd /home/sbaume-consultant01/Documents/tdp/tdp-ops deploy
2024-07-19 10:48:59,189 - INFO - root - Logging is configured.
[WARNING]: Could not match supplied host pattern, ignoring: kafka_broker
[WARNING]: Could not match supplied host pattern, ignoring: zk_kafka_client
[WARNING]: Could not match supplied host pattern, ignoring: zk_kafka
[WARNING]: Could not match supplied host pattern, ignoring: kafka_client
[WARNING]: Could not match supplied host pattern, ignoring: zk_kafka_edge
[WARNING]: Could not match supplied host pattern, ignoring: airflow

PLAY [jmx-exporter install] ****************************************************

TASK [Gathering Facts] *********************************************************
ok: [sbaum-master-01]
ok: [sbaum-worker-01]
ok: [sbaum-master-03]
ok: [sbaum-worker-02]
ok: [sbaum-master-02]
ok: [sbaum-edge-01]
ok: [sbaum-worker-03]

TASK [tosit.tdp.resolve] *******************************************************
ok: [sbaum-master-01]
ok: [sbaum-master-03]
ok: [sbaum-master-02]
ok: [sbaum-worker-02]
ok: [sbaum-worker-03]
ok: [sbaum-worker-01]
ok: [sbaum-edge-01]

TASK [tosit.tdp.jmx : Ensure "/opt/tdp/jmx-exporter" exists] *******************
ok: [sbaum-master-01]
ok: [sbaum-master-03]
ok: [sbaum-worker-01]
ok: [sbaum-edge-01]
ok: [sbaum-worker-02]
ok: [sbaum-master-02]
ok: [sbaum-worker-03]

TASK [tosit.tdp.jmx : Upload jmx-exporter jar] *********************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [sbaum-master-01]: FAILED! => {
    "changed": false
}

MSG:

Could not find or access '/home/sbaume-consultant01/Documents/tdp/tdp-ops/tdp/tdp-lib/files/jmx_prometheus_javaagent-0.16.1.jar' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [sbaum-master-02]: FAILED! => {
    "changed": false
}

MSG:

Could not find or access '/home/sbaume-consultant01/Documents/tdp/tdp-ops/tdp/tdp-lib/files/jmx_prometheus_javaagent-0.16.1.jar' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [sbaum-master-03]: FAILED! => {
    "changed": false
}

MSG:

Could not find or access '/home/sbaume-consultant01/Documents/tdp/tdp-ops/tdp/tdp-lib/files/jmx_prometheus_javaagent-0.16.1.jar' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [sbaum-worker-01]: FAILED! => {
    "changed": false
}

MSG:

Could not find or access '/home/sbaume-consultant01/Documents/tdp/tdp-ops/tdp/tdp-lib/files/jmx_prometheus_javaagent-0.16.1.jar' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [sbaum-worker-02]: FAILED! => {
    "changed": false
}

MSG:

Could not find or access '/home/sbaume-consultant01/Documents/tdp/tdp-ops/tdp/tdp-lib/files/jmx_prometheus_javaagent-0.16.1.jar' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [sbaum-edge-01]: FAILED! => {
    "changed": false
}

MSG:

Could not find or access '/home/sbaume-consultant01/Documents/tdp/tdp-ops/tdp/tdp-lib/files/jmx_prometheus_javaagent-0.16.1.jar' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [sbaum-worker-03]: FAILED! => {
    "changed": false
}

MSG:

Could not find or access '/home/sbaume-consultant01/Documents/tdp/tdp-ops/tdp/tdp-lib/files/jmx_prometheus_javaagent-0.16.1.jar' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
sbaum-edge-01              : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
sbaum-master-01            : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
sbaum-master-02            : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
sbaum-master-03            : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
sbaum-worker-01            : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
sbaum-worker-02            : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
sbaum-worker-03            : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Error: Deployment failed.