-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include datadog_skip_install #431
Conversation
Hi 👋 thanks for sending the PR! While I do agree with the idea of making this configurable, I think that if user provides an explicit value, it should override all further assignments to the variable. I think the way this should work is that we assign e.g. an empty string to the variable in
Does this make sense? |
You mean if the user passes the variable with extra_var/cli? This takes already precedence over the variable in inventory (https://docs.ansible.com/ansible/latest/reference_appendices/general_precedence.html). That said, you are right that currently something is not working. I today learned, that set_fact for variables is not "called" as whole if the variable is passed with extra_vars. This creates problems on boolean variables in newer Ansible versions as cli extra_vars are string type. I always thought one could then call So there could be two solutions:
As the datadog_skip_install isn't used that often I would go with variant 2. Beside the declaration of |
Done... Without the variable set in inventory or cli, the agent will be installed: datadog-agent on main [✘!?] took 7s
❯ ansible-playbook site.yml -i inventories/hosts.yml --limit host01p
PLAY [linux] ***************************************************************************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [set_fact] ************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [include_role : datadog.datadog] **************************************************************************************************************************************************************************************************************************************************************************************
TASK [datadog.datadog : Include Gather Ansible Facts task on Ansible >= 2.10] **********************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/facts-ansible10.yml for host01p
TASK [datadog.datadog : Gather Ansible Facts] ******************************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : Include Gather Ansible Facts task on Ansible < 2.10] ***********************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Check if OS is supported] **************************************************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/os-check.yml for host01p
TASK [datadog.datadog : Fail if OS is not supported] ***********************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Resolve datadog_tracked_checks later to defend against variable presidence issues arising from dynamically included null datadog_checks] ***********************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/sanitize-checks.yml for host01p
TASK [datadog.datadog : Defend against defined but null datadog_checks variable] *******************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : Resolve datadog_tracked_checks] ********************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : Check that datadog_checks is a mapping] ************************************************************************************************************************************************************************************************************************************************************
ok: [host01p] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [datadog.datadog : Set Facts for Datadog Agent Major Version] *********************************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/set-parse-version.yml for host01p
TASK [datadog.datadog : Convert datadog_agent_major_version to string] *****************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : include_tasks] *************************************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Set Agent default major version] *******************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Debian Install Tasks] ******************************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : RedHat Install Tasks] ******************************************************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/pkg-redhat.yml for host01p
...
PLAY RECAP *****************************************************************************************************************************************************************************************************************************************************************************************************************
host01p : ok=12 changed=0 unreachable=0 failed=0 skipped=5 rescued=0 ignored=0 with overriding the variable in cli the install step will be skipped: datadog-agent on main [✘!?] took 7s
❯ ansible-playbook site.yml -i inventories/hosts.yml --limit host01p -e datadog_skip_install=yes
PLAY [linux] ***************************************************************************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [set_fact] ************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [include_role : datadog.datadog] **************************************************************************************************************************************************************************************************************************************************************************************
TASK [datadog.datadog : Include Gather Ansible Facts task on Ansible >= 2.10] **********************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/facts-ansible10.yml for host01p
TASK [datadog.datadog : Gather Ansible Facts] ******************************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : Include Gather Ansible Facts task on Ansible < 2.10] ***********************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Check if OS is supported] **************************************************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/os-check.yml for host01p
TASK [datadog.datadog : Fail if OS is not supported] ***********************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Resolve datadog_tracked_checks later to defend against variable presidence issues arising from dynamically included null datadog_checks] ***********************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/sanitize-checks.yml for host01p
TASK [datadog.datadog : Defend against defined but null datadog_checks variable] *******************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : Resolve datadog_tracked_checks] ********************************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : Check that datadog_checks is a mapping] ************************************************************************************************************************************************************************************************************************************************************
ok: [host01p] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [datadog.datadog : Set Facts for Datadog Agent Major Version] *********************************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/set-parse-version.yml for host01p
TASK [datadog.datadog : Convert datadog_agent_major_version to string] *****************************************************************************************************************************************************************************************************************************************************
ok: [host01p]
TASK [datadog.datadog : include_tasks] *************************************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Set Agent default major version] *******************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Debian Install Tasks] ******************************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : RedHat Install Tasks] ******************************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Suse Install Tasks] ********************************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Windows Install Tasks] *****************************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Linux Configuration Tasks (Agent 5)] ***************************************************************************************************************************************************************************************************************************************************************
skipping: [host01p]
TASK [datadog.datadog : Linux Configuration Tasks] *************************************************************************************************************************************************************************************************************************************************************************
included: /mnt/c/Users/fism/code/work/datadog-agent/roles/datadog.datadog/tasks/agent-linux.yml for host01p
...
I've tested this agains RHEL Linux. Can someone test this with windows? |
Hi 👋
In terms of the |
I think I see what you mean. I had a rough week and going into easter vacation, but will look into it next week. |
Any updates with this PR? We are looking for this exact implementation to be available for our use case. |
I'm going to close this for now as the PR author didn't address the last feedback from our side (and it's been more than 2 years). @amenon90 if you're interested feel free to try to put this into good shape, otherwise we may address #430 at some future time (feel also free to add a comment there so that we can keep record of this still being a relevant feature). |
Heja there all, yeah I now stumbled upon this again - somehow that got overlooked totally by me. But now I would need that again too. |
fixes #430