redhat-cop / infra.aap_configuration

A collection of roles to manage Ansible Controller and previously Ansible Tower
https://galaxy.ansible.com/infra/controller_configuration
GNU General Public License v3.0
268 stars 141 forks source link

Schedules: requires template ask_variables_on_launch and ask_verbosity_on_launch to be set to true #878

Closed amunro-tsl closed 2 months ago

amunro-tsl commented 2 months ago

Summary

When creating a schedule for the first time, these need to set to true in the template, otherwise an error is reported:

ask_variables_on_launch: true
ask_verbosity_on_launch: true

Error reported:

"msg": "Unable to create schedule helix_test: {'verbosity': ['Field is not configured to prompt on launch.'], 'extra_data': ['Variables scheduled are not allowed on launch. Check the Prompt on Launch setting on the Job Template to include Extra Variables.']}"

Once the schedule is created, you can set these back to false, which is a work around.

Note that we have variables defined in the inventory resource.

So the question is why do schedules need these settings, when we don't want to set them? Are we using this incorrectly or miss understanding something? We should be able to set these to false?

Issue Type

Ansible, Collection, Controller details

infra.controller_configuration 2.9.0 (latest).

$ ansible --version
ansible [core 2.15.12]
  config file = /media/data/other-git/genomicsengland/gitlab/infra_services/config-mgt/ansible/aap/infrastructure-services-config/ansible.cfg
  configured module search path = ['/home/amunro/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/site-packages/ansible
  ansible collection location = /home/amunro/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/linuxbrew/.linuxbrew/bin/ansible
  python version = 3.11.4 (main, Jun  6 2023, 22:16:46) [GCC 11.3.0] (/home/linuxbrew/.linuxbrew/opt/python@3.11/bin/python3.11)
  jinja version = 3.1.4
  libyaml = True
$ ansible-galaxy collection list

# /home/amunro/.ansible/collections/ansible_collections
Collection                     Version
------------------------------ -------
amazon.aws                     7.5.0  
ansible.controller             4.5.6  
infra.ah_configuration         2.0.6  
infra.controller_configuration 2.9.0  

# /home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/site-packages/ansible_collections
Collection                     Version
------------------------------ -------
amazon.aws                     6.5.0  
ansible.netcommon              5.3.0  
ansible.posix                  1.5.4  
ansible.utils                  2.12.0 
ansible.windows                1.14.0 
arista.eos                     6.2.2  
awx.awx                        22.7.0 
azure.azcollection             1.19.0 
check_point.mgmt               5.1.1  
chocolatey.chocolatey          1.5.1  
cisco.aci                      2.8.0  
cisco.asa                      4.0.3  
cisco.dnac                     6.9.0  
cisco.intersight               1.0.27 
cisco.ios                      4.6.1  
cisco.iosxr                    5.0.3  
cisco.ise                      2.6.2  
cisco.meraki                   2.17.0 
cisco.mso                      2.5.0  
cisco.nso                      1.0.3  
cisco.nxos                     4.4.0  
cisco.ucs                      1.10.0 
cloud.common                   2.1.4  
cloudscale_ch.cloud            2.3.1  
community.aws                  6.4.0  
community.azure                2.0.0  
community.ciscosmb             1.0.7  
community.crypto               2.16.1 
community.digitalocean         1.24.0 
community.dns                  2.6.4  
community.docker               3.4.11 
community.fortios              1.0.0  
community.general              7.5.2  
community.google               1.0.0  
community.grafana              1.6.1  
community.hashi_vault          5.0.1  
community.hrobot               1.8.2  
community.libvirt              1.3.0  
community.mongodb              1.6.3  
community.mysql                3.8.0  
community.network              5.0.2  
community.okd                  2.3.0  
community.postgresql           2.4.3  
community.proxysql             1.5.1  
community.rabbitmq             1.2.3  
community.routeros             2.11.0 
community.sap                  1.0.0  
community.sap_libs             1.4.1  
community.skydive              1.0.0  
community.sops                 1.6.7  
community.vmware               3.11.1 
community.windows              1.13.0 
community.zabbix               2.2.0  
containers.podman              1.11.0 
cyberark.conjur                1.2.2  
cyberark.pas                   1.0.23 
dellemc.enterprise_sonic       2.2.0  
dellemc.openmanage             7.6.1  
dellemc.powerflex              1.9.0  
dellemc.unity                  1.7.1  
f5networks.f5_modules          1.27.1 
fortinet.fortimanager          2.3.0  
fortinet.fortios               2.3.4  
frr.frr                        2.0.2  
gluster.gluster                1.0.2  
google.cloud                   1.3.0  
grafana.grafana                2.2.3  
hetzner.hcloud                 1.16.0 
hpe.nimble                     1.1.4  
ibm.qradar                     2.1.0  
ibm.spectrum_virtualize        1.12.0 
ibm.storage_virtualize         2.1.0  
infinidat.infinibox            1.3.12 
infoblox.nios_modules          1.5.0  
inspur.ispim                   1.3.0  
inspur.sm                      2.3.0  
junipernetworks.junos          5.3.1  
kubernetes.core                2.4.0  
lowlydba.sqlserver             2.2.2  
microsoft.ad                   1.4.1  
netapp.aws                     21.7.1 
netapp.azure                   21.10.1
netapp.cloudmanager            21.22.1
netapp.elementsw               21.7.0 
netapp.ontap                   22.8.3 
netapp.storagegrid             21.11.1
netapp.um_info                 21.8.1 
netapp_eseries.santricity      1.4.0  
netbox.netbox                  3.15.0 
ngine_io.cloudstack            2.3.0  
ngine_io.exoscale              1.1.0  
ngine_io.vultr                 1.1.3  
openstack.cloud                2.2.0  
openvswitch.openvswitch        2.1.1  
ovirt.ovirt                    3.2.0  
purestorage.flasharray         1.24.0 
purestorage.flashblade         1.14.0 
purestorage.fusion             1.6.0  
sensu.sensu_go                 1.14.0 
servicenow.servicenow          1.0.6  
splunk.es                      2.1.2  
t_systems_mms.icinga_director  1.33.1 
telekom_mms.icinga_director    1.35.0 
theforeman.foreman             3.15.0 
vmware.vmware_rest             2.3.1  
vultr.cloud                    1.11.0 
vyos.vyos                      4.1.0  
wti.remote                     1.0.5  

Controller version: 4.5.7

OS / ENVIRONMENT

Desired Behavior

Actual Behavior

Please give some details of what is actually happening. Include a [minimum complete verifiable example] with:

STEPS TO REPRODUCE

---
controller_projects:
  # Schedules cannot differentiate between a project and template named the same (eg helix_test), returns 2 items and fails. Thus helix_test Project.
  - name: helix_test Project
    organization: Infrastructure_Services
    scm_branch: INS-000/helix-test
    scm_type: git
    scm_update_on_launch: true
    scm_url: https://gitlab.com/genomicsengland/infra_services/config_mgt/ansible/cluster-double-helix.git
    credential: "GEL Gitlab - ansible read"
    notification_templates_error: Slack ansible_alerts

---
controller_templates:
- name: helix_test
  job_type: run
  organization: Infrastructure_Services
  inventory: helix_test
  project: helix_test Project
  execution_environment: Automation Hub Default execution environment
  playbook: site.yml
  credentials:
  - helix_test
  instance_groups:
  - ansible_dev
  verbosity: 0
  become_enabled: true
  notification_templates_error: Slack ansible_alerts
  # next two settings will need to be set to be set temporarily to true to allow the schedule to be created. 
  # Once created, these can then be set to false, which is what we want.
  ask_variables_on_launch: false
  ask_verbosity_on_launch: false

---
controller_inventories:
  - name: helix_test
    organization: Infrastructure_Services
    variables:
      ansible_connection: ssh
      ansible_user: ansible
      ansible_become_user: root

---
controller_schedules:
  - name: helix_test
    organization: Infrastructure_Services
    description: Run helix_test template on a schedule so we are alerted when AAP has issue running jobs
    unified_job_template: helix_test
    rrule: "DTSTART:20240721T000000Z RRULE:FREQ=HOURLY;INTERVAL=4"
    extra_data:
      scheduled: true
    verbosity: 1
Tompage1994 commented 2 months ago

This is by design. The schedule needs to be able to apply the item to the job template so it does need to have prompt on launch for the things you're setting.

Because you're trying to set extra_data and verbosity on the schedule, you're trying to set these items as though they've been prompted for.

You'll find the same behaviour if you try to create through the API or in the UI that you can't apply those options unless they're set to be prompted on launch. I suspect (though haven't tried) that if you disable the prompt_on_launch_XXX, then the overridden values will not actually be set during the schedule.

I'm going to close this as it's not really something which this collection can assist with and it's more of an 'issue' with Controller itself.

amunro-tsl commented 2 months ago

For anyone who followed the example in the collection documentation, this is a simple example that does not cause the issue I experienced (which expects template non default values).

---
controller_schedules:
  - name: helix_test
    organization: Infrastructure_Services
    description: Run helix_test template on a schedule so we are alerted when AAP has issue running jobs
    unified_job_template: helix_test
    rrule: "DTSTART:20240721T000000Z RRULE:FREQ=HOURLY;INTERVAL=4"

@Tompage1994 might I suggest a documentation update to have a simple example like above? As someone new to automation controller I would not know what all the settings are and would use the example in the documentation as a starting point. BTW many thanks for your help!

Tompage1994 commented 2 months ago

@amunro-tsl I've just raised #881

amunro-tsl commented 2 months ago

Thanks for all your help @Tompage1994