diff --git a/extensions/patterns/manage_service/exec_env/.gitignore b/extensions/patterns/manage_service/exec_env/.gitignore new file mode 100644 index 0000000..8fe9bbb --- /dev/null +++ b/extensions/patterns/manage_service/exec_env/.gitignore @@ -0,0 +1 @@ +context/** diff --git a/extensions/patterns/manage_service/exec_env/README.md b/extensions/patterns/manage_service/exec_env/README.md new file mode 100644 index 0000000..1e54544 --- /dev/null +++ b/extensions/patterns/manage_service/exec_env/README.md @@ -0,0 +1,8 @@ +Build EE manually, push to quay.io + +``` +ansible-builder build +# podman build -f context/Containerfile -t ansible-execution-env:latest context +podman tag ansible-execution-env:latest quay.io/p3ck/apd-ee-25-experience:latest +podman push quay.io/p3ck/apd-ee-25-experience:latest +``` diff --git a/extensions/patterns/manage_service/exec_env/execution-environment.yml b/extensions/patterns/manage_service/exec_env/execution-environment.yml new file mode 100644 index 0000000..241fae4 --- /dev/null +++ b/extensions/patterns/manage_service/exec_env/execution-environment.yml @@ -0,0 +1,13 @@ +--- +version: 3 +images: + base_image: + name: quay.io/ansible-product-demos/apd-ee-25:latest +dependencies: + galaxy: requirements.yml + ansible_core: + package_pip: ansible-core + ansible_runner: + package_pip: ansible-runner + system: + - podman diff --git a/extensions/patterns/manage_service/exec_env/requirements.yml b/extensions/patterns/manage_service/exec_env/requirements.yml new file mode 100644 index 0000000..9a63a89 --- /dev/null +++ b/extensions/patterns/manage_service/exec_env/requirements.yml @@ -0,0 +1,6 @@ +--- +collections: + # - name: ansible.experience_demo + - name: https://github.com/redhat-cop/infra.windows_ops.git + type: git + version: main diff --git a/extensions/patterns/manage_service/playbooks/run_manage_service.yml b/extensions/patterns/manage_service/playbooks/run_manage_service.yml new file mode 100644 index 0000000..9c45572 --- /dev/null +++ b/extensions/patterns/manage_service/playbooks/run_manage_service.yml @@ -0,0 +1,13 @@ +--- +- name: Manage Windows Services + hosts: all + gather_facts: false + tasks: + - name: Manage Windows Service + ansible.builtin.include_role: + name: infra.windows_ops.windows_manage_service + vars: + windows_manage_service_name: "{{ service_name }}" # Set by survey + windows_manage_service_state: "{{ service_state }}" # Set by survey + windows_manage_service_start_mode: "{{ service_start_mode }}" # Set by survey +... diff --git a/extensions/patterns/manage_service/setup.yml b/extensions/patterns/manage_service/setup.yml new file mode 100644 index 0000000..1e433b9 --- /dev/null +++ b/extensions/patterns/manage_service/setup.yml @@ -0,0 +1,47 @@ +--- +# Labels +# +controller_labels: + - name: infra.windows_ops + organization: "{{ organization | default('Default') }}" + - name: manage_service_pattern + organization: "{{ organization | default('Default') }}" + - name: run_manage_service + organization: "{{ organization | default('Default') }}" + +# Execution Environments +# +controller_execution_environments: + - name: apd-ee-25-windows + description: Allow running Windows experience demo. Based on apd-ee-25. + image: quay.io/p3ck/apd-ee-25-experience:latest + pull: always + +# Projects +# +controller_projects: + - name: Windows Operations / Project + organization: Default + scm_branch: main + scm_clean: 'no' + scm_delete_on_update: 'no' + scm_type: git + scm_update_on_launch: 'yes' + scm_url: https://github.com/redhat-cop/infra.windows_ops.git + + +# Job Templates +# +controller_templates: + - name: Windows Operations / Manage Service + ask_inventory_on_launch: true + labels: + - infra.windows_ops + - manage_service_pattern + - run_manage_service + playbook: "extensions/patterns/manage_service/playbooks/run_manage_service.yml' }}" + project: Windows Operations / Project + survey_enabled: true + survey_spec: "{{ lookup('file', pattern.path.replace('setup.yml', '') + 'template_surveys/manage_service.yml') | from_yaml }}" + ask_credential_on_launch: true + execution_environment: apd-ee-25-windows diff --git a/extensions/patterns/manage_service/template_surveys/manage_services.yml b/extensions/patterns/manage_service/template_surveys/manage_services.yml new file mode 100644 index 0000000..b62ea55 --- /dev/null +++ b/extensions/patterns/manage_service/template_surveys/manage_services.yml @@ -0,0 +1,33 @@ +--- +name: "Manage Service Configuration Survey" +description: "Survey to configure manage service options" +spec: + - question_name: "Service Name" + question_description: "Specify the Windows Service you would like to manage" + required: true + variable: "service_name" + type: "text" + + - question_name: "Service State" + question_description: "Specify the state of the Service" + required: true + variable: "service_state" + type: "multiplechoice" + choices: + - "absent" + - "paused" + - "started" + - "stopped" + - "restarted" + + - question_name: "Start mode" + question_description: "Set the startup mode for the Service" + required: false + variable: "service_start_mode" + type: "multplechoice" + choices: + - "auto" + - "delayed" + - "disabled" + - "manual" + default: "auto" diff --git a/roles/windows_manage_service/defaults/main.yml b/roles/windows_manage_service/defaults/main.yml new file mode 100644 index 0000000..bdcd541 --- /dev/null +++ b/roles/windows_manage_service/defaults/main.yml @@ -0,0 +1,2 @@ +--- +windows_manage_service_start_mode: "auto" diff --git a/roles/windows_manage_service/meta/argument_specs.yml b/roles/windows_manage_service/meta/argument_specs.yml new file mode 100644 index 0000000..2d79613 --- /dev/null +++ b/roles/windows_manage_service/meta/argument_specs.yml @@ -0,0 +1,31 @@ +--- +argument_specs: + main: + version_added: 1.0.0 + short_description: A role to Manage Windows Services. + description: + - A role to Manage Windows Services. + options: + windows_manage_service_name: + type: str + description: The name of the service. + required: true + windows_manage_service_state: + type: str + choices: + - "absent" + - "paused" + - "started" + - "stopped" + - "restarted" + required: true + description: The state of the service. + windows_manage_service_start_mode: + type: str + choices: + - "auto" + - "delayed" + - "disabled" + - "manual" + default: "auto" + description: The start mode of the service. diff --git a/roles/windows_manage_service/tasks/main.yml b/roles/windows_manage_service/tasks/main.yml new file mode 100644 index 0000000..e9727a5 --- /dev/null +++ b/roles/windows_manage_service/tasks/main.yml @@ -0,0 +1,18 @@ +--- +# tasks file for windows_manage_service + +- name: Manage Windows Service + ansible.windows.win_service: + name: "{{ windows_manage_service_name }}" + state: "{{ windows_manage_service_state }}" + start_mode: "{{ windows_manage_service_start_mode }}" + +- name: Check Win Service + ansible.windows.win_service_info: + name: "{{ windows_manage_service_name }}" + register: windows_manage_service_status + +- name: Display Win Service + ansible.builtin.debug: + var: windows_manage_service_status +...