From 6412c17e51ee2cb48f71577af1ae4e25b1dec2d5 Mon Sep 17 00:00:00 2001 From: MKletz Date: Tue, 15 Feb 2022 13:21:10 -0600 Subject: [PATCH] Added Windows templates (#1) add windows demos --- README.md | 3 +- collections/requirements.yml | 4 +- windows/install_iis.yml | 25 +++++++ windows/setup.yml | 116 +++++++++++++++++++++++++++++ windows/windows_choco_multiple.yml | 29 ++++++++ windows/windows_choco_specific.yml | 9 +++ windows/windows_updates.yml | 9 +++ 7 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 windows/install_iis.yml create mode 100644 windows/setup.yml create mode 100644 windows/windows_choco_multiple.yml create mode 100644 windows/windows_choco_specific.yml create mode 100644 windows/windows_updates.yml diff --git a/README.md b/README.md index d861e58..bc07e3a 100644 --- a/README.md +++ b/README.md @@ -38,5 +38,4 @@ Please push contributions via a pull request following the naming convention of - Name: Controller Credential - Extra vars: - demo: linux - + demo: diff --git a/collections/requirements.yml b/collections/requirements.yml index ade28c1..df9baa3 100644 --- a/collections/requirements.yml +++ b/collections/requirements.yml @@ -7,4 +7,6 @@ collections: - redhat.insights - redhat.rhel_system_roles - community.general - - containers.podman \ No newline at end of file + - containers.podman + #windows + - chocolatey.chocolatey diff --git a/windows/install_iis.yml b/windows/install_iis.yml new file mode 100644 index 0000000..2b84612 --- /dev/null +++ b/windows/install_iis.yml @@ -0,0 +1,25 @@ +--- +- name: Install IIS + hosts: "{{ HOSTS | default('windows') }}" + vars: + iis_message: undef + + tasks: + - name: Install IIS + win_feature: + name: Web-Server + state: present + + - name: Start IIS service + win_service: + name: W3Svc + state: started + + - name: Create website index.html + win_copy: + content: "{{ iis_message }}" + dest: C:\Inetpub\wwwroot\index.html + + - name: Show website address + debug: + msg: http://{{ ansible_host }} diff --git a/windows/setup.yml b/windows/setup.yml new file mode 100644 index 0000000..2013429 --- /dev/null +++ b/windows/setup.yml @@ -0,0 +1,116 @@ +--- +controller_components: + - projects + - job_templates + +controller_projects: + - name: Fact Scan + organization: Default + scm_type: git + scm_url: 'https://github.com/ansible/awx-facts-playbooks.git' + +controller_templates: + - name: "WINDOWS / Install IIS" + job_type: run + inventory: "Workshop Inventory" + project: "Ansible official demo project" + playbook: "windows/install_iis.yml" + execution_environment: Default execution environment + credentials: + - "Workshop Credential" + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Server Name or Pattern + type: text + variable: HOSTS + required: false + - question_name: web content + type: text + variable: iis_message + required: true + + - name: "WINDOWS / Windows updates" + job_type: run + inventory: "Workshop Inventory" + project: "Ansible official demo project" + playbook: "windows/windows_updates.yml" + execution_environment: Default execution environment + credentials: + - "Workshop Credential" + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Server Name or Pattern + type: text + variable: HOSTS + required: false + - question_name: Update categories + type: multiplechoice + variable: categories + required: false + default: SecurityUpdates + choices: + - Application + - Connectors + - CriticalUpdates + - DefinitionUpdates + - DeveloperKits + - FeaturePacks Guidance + - SecurityUpdates + - ServicePacks + - Tools + - UpdateRollups + - Updates + - question_name: Reboot after install? + type: multiplechoice + variable: reboot_server + required: false + default: 'Yes' + choices: + - 'Yes' + - 'No' + + - name: "WINDOWS / Chocolatey install multiple" + job_type: run + inventory: "Workshop Inventory" + project: "Ansible official demo project" + playbook: "windows/windows_choco_multiple.yml" + execution_environment: Default execution environment + credentials: + - "Workshop Credential" + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Server Name or Pattern + type: text + variable: HOSTS + required: false + + - name: "WINDOWS / Chocolatey install specific" + job_type: run + inventory: "Workshop Inventory" + project: "Ansible official demo project" + playbook: "windows/windows_choco_specific.yml" + execution_environment: Default execution environment + credentials: + - "Workshop Credential" + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Server Name or Pattern + type: text + variable: HOSTS + required: false + - question_name: Package name + type: text + variable: package_name + required: true diff --git a/windows/windows_choco_multiple.yml b/windows/windows_choco_multiple.yml new file mode 100644 index 0000000..83ea42b --- /dev/null +++ b/windows/windows_choco_multiple.yml @@ -0,0 +1,29 @@ +--- +- name: Chocolatey install multiple + hosts: "{{ HOSTS | default('windows') }}" + gather_facts: false + vars: + choco_packages: + - name: nodejs + version: 13.0.0 + - name: python + version: 3.6.0 + tasks: + - name: Install specific versions of packages sequentially + win_chocolatey: + name: "{{ item.name }}" + version: "{{ item.version }}" + loop: "{{ choco_packages }}" + + - name: Check python version + win_command: python --version + register: check_python_version + changed_when: false + + - name: Check nodejs version + win_command: node --version + register: check_node_version + changed_when: false + + - debug: + msg: Python Version is {{ check_python_version.stdout_lines[0] }} and NodeJS version is {{ check_node_version.stdout_lines[0] }} diff --git a/windows/windows_choco_specific.yml b/windows/windows_choco_specific.yml new file mode 100644 index 0000000..5f034ec --- /dev/null +++ b/windows/windows_choco_specific.yml @@ -0,0 +1,9 @@ +--- +- name: Chocolatey install specific + hosts: "{{ HOSTS | default('windows') }}" + gather_facts: false + + tasks: + - name: Install choco package with specific version + win_chocolatey: + name: "{{ package_name }}" diff --git a/windows/windows_updates.yml b/windows/windows_updates.yml new file mode 100644 index 0000000..ac97e3e --- /dev/null +++ b/windows/windows_updates.yml @@ -0,0 +1,9 @@ +--- +- name: Windows updates + hosts: "{{ HOSTS | default('windows') }}" + + tasks: + - name: Install Windows Updates + win_updates: + category_names: "{{ categories | default(omit) }}" + reboot: '{{ reboot_server | default(yes) }}'