Skip to content
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

Remove Workflow with controller_state: absent failed #891

Open
wbrandt-az opened this issue Aug 7, 2024 · 2 comments
Open

Remove Workflow with controller_state: absent failed #891

wbrandt-az opened this issue Aug 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@wbrandt-az
Copy link

Summary

I create a project with credentials, project, job template and workflow templates using the infra.controlle_configuration collection.
For testing I create also a cleanup Playbook and set the variable controller_state to absent.
It will remove all resources from my Organization except Workflows. due to a fix order of removing workflows (Workflow, Workflow-Node, Node-Links) it will fail at removing Workflow-Nodes due to missing Workflow, which was already removed.

Issue Type

  • Bug Report

Ansible, Collection, Controller details

Collection: infra.controller_configuration

Ansible Version:
ansible [core 2.17.2]
  config file = /home/runner/_work/aip-configuration/aip-configuration/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/runner/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/runner/.local/bin/ansible
  python version = 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

ansible-galaxy collection list

Controller version
Ansible Automation Platform Controller 4.5.7
  • ansible installation method: one of source, pip, OS package, EE

OS / ENVIRONMENT

Desired Behavior

  1. create Workflow using
    collection: infra.controller_configuration.workflow_job_templates
    with default variable value controller_state: present

  2. remove Workflow using
    collection: infra.controller_configuration.workflow_job_templates
    with default variable value controller_state: absent

after step 2 the Workflow including Workflow Nodes are removed from Organization.

Actual Behavior

collection: infra.controller_configuration.workflow_job_templates
with default variable value controller_state: absent

=> Playbook will fail.

- name: Cleanup project
  hosts: localhost
  connection: local
  become: false
  gather_facts: false
  vars:
    controller_state: absent
  tasks:
    - name: Create workflows
      ansible.builtin.include_role:
        name: infra.controller_configuration.workflow_job_templates
      when: controller_workflows is defined
"msg": "The workflow SSR-add new customer team in organization WFTEST was not found on the controller instance server"

STEPS TO REPRODUCE

@wbrandt-az wbrandt-az added bug Something isn't working new New issue, this should be removed once reviewed labels Aug 7, 2024
@djdanielsson
Copy link
Collaborator

sorry it has taken so long to get to this, can you show the vars for one of the workflows? if I were to guess you have state present there which over rides that global option

@djdanielsson djdanielsson removed the new New issue, this should be removed once reviewed label Nov 14, 2024
@wbrandt-az
Copy link
Author

Many thanks to take this.
Here is my example code:

---
controller_workflows:
  - name: InstallApacheWorkflow
    description: Workflow to install Apache and deploy WebApp
    organization: AIP-O-WBDEMO
#    state: present   # use controller_state centrally
    inventory: Demo-inventory
    survey_enabled: false
    survey_spec: {}
    limit: euDev
    ask_limit_on_launch: true
    extra_vars: {}
    simplified_workflow_nodes:
      - name: install Apache
        identifier: installApache
#        state: present   # use controller_state centrally
        unified_job_template: aipdemo-Install Apache
        success_nodes:
          - Approval_Apache_Installation
        failure_nodes: []
        always_nodes: []
      - identifier: Approval_Apache_Installation
        approval_node:
          name: Approval Apache Installation
          description: " Apache Installation ok?"
          timeout: 3600
        success_nodes:
          - DeployContent
        failure_nodes:
          - Uninstall Apache
        always_nodes: []
      - name: Deploy Content
        identifier: DeployContent
#        state: present   # use controller_state centrally
        unified_job_template: aipdemo-DeployWebPage
        success_nodes: []
        failure_nodes: []
        always_nodes: []
      - name: UninstallApache
        identifier: Uninstall Apache
#        state: present   # use controller_state centrally
        unified_job_template: aipdemo-UnInstall Apache
        success_nodes: []
        failure_nodes: []
        always_nodes: []

Playbook:

---
- name: Playbook to setup Project in ansible controller
  hosts: localhost
  connection: local
  vars:
    controller_state: absent

  tasks:
    - name: Set project_config_dir
      ansible.builtin.set_fact:
        project_config_dir: "{{ controller_configs_dir | default((lookup('env', 'CONTROLLER_CONFIGS_DIR') == '') | ternary('./aap_config', lookup('env', 'CONTROLLER_CONFIGS_DIR'))) }}"     # noqa yaml[line-length]

    - name: Include PWD
      ansible.builtin.include_vars:
        file: "{{ project_config_dir }}/encrypt.yml"
      tags:
        - always
#      no_log: true
    - name: Templateing controller_auth
      ansible.builtin.template:
        src: "{{ project_config_dir }}/controller_auth.yml.j2"
        dest: "{{ project_config_dir }}/controller_auth.yml"
        mode: '0600'
      run_once: true
#      no_log: true
    - name: Templateing credentials
      ansible.builtin.template:
        src: "{{ project_config_dir }}/credentials.yml.j2"
        dest: "{{ project_config_dir }}/credentials.yml"
        mode: '0600'
      run_once: true
#      no_log: true

    - name: Include vars from configs directory
      ansible.builtin.include_vars:
        dir: "{{ project_config_dir }}"
        ignore_unknown_extensions: true
        extensions: ["yml"]
      tags:
        - always

    - name: Call dispatch role
      ansible.builtin.include_role:
        name: infra.controller_configuration.dispatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants