lint fixes

This commit is contained in:
willtome
2023-03-07 09:26:22 -05:00
parent 36f113aa75
commit 745b755296
57 changed files with 525 additions and 1135 deletions

View File

@@ -3,5 +3,5 @@
name: Rollback playbook
tasks:
- name: "Rollback this step"
debug:
ansible.builtin.debug:
msg: "Rolling back this step"

View File

@@ -1,50 +1,50 @@
---
- name: Create Active Directory domain
hosts: "{{ HOSTS | default('os_windows') }}"
hosts: "{{ _hosts | default('os_windows') }}"
gather_facts: false
tasks:
- name: Set Local Admin Password
ansible.windows.win_user:
name: Administrator
password: "{{ ansible_password }}"
- name: Set Local Admin Password
ansible.windows.win_user:
name: Administrator
password: "{{ ansible_password }}"
- name: Create new domain in a new forest on the target host
ansible.windows.win_domain:
dns_domain_name: ansible.local
safe_mode_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
register: new_forest
- name: Create new domain in a new forest on the target host
ansible.windows.win_domain:
dns_domain_name: ansible.local
safe_mode_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
register: new_forest
- name: Reboot the target host
ansible.windows.win_reboot:
reboot_timeout: 3600
when: new_forest.reboot_required
- name: Reboot the target host
ansible.windows.win_reboot:
reboot_timeout: 3600
when: new_forest.reboot_required
- name: Wait up to 10min for AD web services to start
community.windows.win_wait_for_process:
process_name_exact: Microsoft.ActiveDirectory.WebServices
pre_wait_delay: 60
state: present
timeout: 600
sleep: 10
remote_user: Administrator
- name: Wait up to 10min for AD web services to start
community.windows.win_wait_for_process:
process_name_exact: Microsoft.ActiveDirectory.WebServices
pre_wait_delay: 60
state: present
timeout: 600
sleep: 10
remote_user: Administrator
- name: Create some groups
community.windows.win_domain_group:
name: "{{ item.name }}"
scope: global
loop:
- { name: "GroupA" }
- { name: "GroupB" }
- { name: "GroupC" }
- name: Create some groups
community.windows.win_domain_group:
name: "{{ item.name }}"
scope: global
loop:
- { name: "GroupA" }
- { name: "GroupB" }
- { name: "GroupC" }
- name: Create some users
community.windows.win_domain_user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
update_password: on_create
loop:
- { name: "UserA", groups: "GroupA" }
- { name: "UserB", groups: "GroupB" }
- { name: "UserC", groups: "GroupC" }
- name: Create some users
community.windows.win_domain_user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
update_password: on_create
loop:
- { name: "UserA", groups: "GroupA" }
- { name: "UserB", groups: "GroupB" }
- { name: "UserC", groups: "GroupC" }

View File

@@ -1,39 +1,39 @@
---
- name: Helpdesk new user portal
hosts: "{{ HOSTS | default('windows') }}"
hosts: "{{ _hosts | default('windows') }}"
gather_facts: false
tasks:
- name: Setting host facts using complex arguments
set_fact:
temp_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
# Example result: ['&Qw2|E[-']
- name: Setting host facts using complex arguments
ansible.builtin.set_fact:
temp_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
# Example result: ['&Qw2|E[-']
- name: Create new user
community.windows.win_domain_user:
name: "{{ firstname }} {{ surname }}"
firstname: "{{ firstname }}"
surname: "{{ surname }}"
sam_account_name: "{{ firstname[0] }}{{ surname }}"
company: BobCo
password: "{{ temp_password }}"
state: present
groups:
- "GroupA"
- "GroupB"
street: "{{ street }}"
city: "{{ city }}"
state_province: IN
postal_code: "{{ postal_code }}"
country: US
attributes:
telephoneNumber: "{{ telephone_number }}"
register: new_user
- name: Create new user
community.windows.win_domain_user:
name: "{{ firstname }} {{ surname }}"
firstname: "{{ firstname }}"
surname: "{{ surname }}"
sam_account_name: "{{ firstname[0] }}{{ surname }}"
company: BobCo
password: "{{ temp_password }}"
state: present
groups:
- "GroupA"
- "GroupB"
street: "{{ street }}"
city: "{{ city }}"
state_province: IN
postal_code: "{{ postal_code }}"
country: US
attributes:
telephoneNumber: "{{ telephone_number }}"
register: new_user
- name: Display User
debug:
var: new_user
- name: Display User
ansible.builtin.debug:
var: new_user
- name: Show temp password
debug:
var: temp_password
- name: Show temp password
ansible.builtin.debug:
var: temp_password

View File

@@ -1,25 +1,25 @@
---
- name: Install IIS
hosts: "{{ HOSTS | default('windows') }}"
hosts: "{{ _hosts | default('windows') }}"
vars:
iis_message: undef
tasks:
- name: Install IIS
win_feature:
ansible.windows.win_feature:
name: Web-Server
state: present
- name: Start IIS service
win_service:
ansible.windows.win_service:
name: W3Svc
state: started
- name: Create website index.html
win_copy:
ansible.windows.win_copy:
content: "{{ iis_message }}"
dest: C:\Inetpub\wwwroot\index.html
- name: Show website address
debug:
ansible.builtin.debug:
msg: http://{{ ansible_host }}

View File

@@ -1,25 +1,28 @@
---
- name: Windows updates
hosts: "{{ HOSTS | default('os_windows') }}"
hosts: "{{ _hosts | default('os_windows') }}"
strategy: linear
vars:
report_server: win1
tasks:
- include_role:
name: demo.patching.patch_windows
- name: Patch windows server
ansible.builtin.include_role:
name: demo.patching.patch_windows
- block:
- name: Build report server
delegate_to: "{{ report_server }}"
run_once: true
block:
- name: Install report server
ansible.builtin.include_role:
name: "{{ item }}"
loop:
- demo.patching.report_server
- demo.patching.report_windows
- demo.patching.report_windows_patching
- include_role:
name: "{{ item }}"
loop:
- demo.patching.report_server
- demo.patching.report_windows
- demo.patching.report_windows_patching
- include_role:
name: demo.patching.report_server
tasks_from: windows_landing_page
delegate_to: "{{ report_server }}"
run_once: yes
- name: Update landing page
ansible.builtin.include_role:
name: demo.patching.report_server
tasks_from: windows_landing_page

View File

@@ -1,16 +1,17 @@
---
- name: Run PowerShell
hosts: "{{ HOSTS | default('windows') }}"
hosts: "{{ _hosts | default('os_windows') }}"
gather_facts: false
vars:
ps_script: undef
tasks:
- name: Run PowerShell
ansible.windows.win_powershell:
script: |
{{ ps_script }}
register: ps_output
- name: Run PowerShell
ansible.windows.win_powershell:
script: |
{{ ps_script }}
register: ps_output
- debug:
msg: "{{ ps_output.output }}"
- name: Print output
ansible.builtin.debug:
msg: "{{ ps_output.output }}"

View File

@@ -1,42 +1,42 @@
---
- name: PowerShell DSC
hosts: "{{ HOSTS | default('windows') }}"
hosts: "{{ _hosts | default('os_windows') }}"
gather_facts: false
tasks:
- name: Setup the SecurityPolicyDSC module
community.windows.win_psmodule:
name: SecurityPolicyDSC
module_version: 2.10.0.0
state: present
accept_license: yes
- name: Set password history
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Enforce_password_history
Enforce_password_history: 24
- name: Setup the SecurityPolicyDSC module
community.windows.win_psmodule:
name: SecurityPolicyDSC
module_version: 2.10.0.0
state: present
accept_license: true
- name: Set maximum password age
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Maximum_Password_Age
Maximum_Password_Age: 60
- name: Set password history
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Enforce_password_history
Enforce_password_history: 24
- name: Set minimum password age
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Minimum_Password_Age
Maximum_Password_Age: 20
- name: Set maximum password age
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Maximum_Password_Age
Maximum_Password_Age: 60
- name: Set minimum password length
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Minimum_Password_Length
Maximum_Password_Age: 8
- name: Set minimum password age
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Minimum_Password_Age
Maximum_Password_Age: 20
- name: Set password complexity requirements
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Password_must_meet_complexity_requirements
Password_must_meet_complexity_requirements: Enabled
- name: Set minimum password length
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Minimum_Password_Length
Maximum_Password_Age: 8
- name: Set password complexity requirements
ansible.windows.win_dsc:
resource_name: AccountPolicy
Name: Password_must_meet_complexity_requirements
Password_must_meet_complexity_requirements: Enabled

View File

@@ -1,20 +1,22 @@
---
- name: PowerShell Script
hosts: "{{ HOSTS | default('windows') }}"
hosts: "{{ _hosts | default('os_windows') }}"
gather_facts: false
vars:
remote_dest: "C:\\query_services.ps1"
tasks:
- name: Copy script to remote
ansible.windows.win_copy:
src: "{{playbook_dir}}/query_services.ps1"
dest: "{{ remote_dest }}"
- name: Run Script
ansible.windows.win_powershell:
script: |
{{ remote_dest }} -ServiceState {{ service_state }}
register: ps_output
- debug:
var: ps_output
tasks:
- name: Copy script to remote
ansible.windows.win_copy:
src: "{{ playbook_dir }}/query_services.ps1"
dest: "{{ remote_dest }}"
- name: Run Script
ansible.windows.win_powershell:
script: |
{{ remote_dest }} -ServiceState {{ service_state }}
register: ps_output
- name: Print output
ansible.builtin.debug:
var: ps_output

View File

@@ -22,7 +22,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -30,7 +30,7 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- question_name: web content
type: text
@@ -40,7 +40,7 @@ controller_templates:
- name: "WINDOWS / Patching"
use_fact_cache: true
job_type: check
ask_job_type_on_launch: yes
ask_job_type_on_launch: true
inventory: "Workshop Inventory"
project: "Ansible official demo project"
playbook: "windows/patching.yml"
@@ -49,7 +49,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -57,7 +57,7 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- question_name: Update categories
type: multiselect
@@ -94,7 +94,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -102,7 +102,7 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- name: "WINDOWS / Chocolatey install specific"
@@ -114,7 +114,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -122,7 +122,7 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- question_name: Package name
type: text
@@ -138,7 +138,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -146,9 +146,9 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- question_name: PowerShell Script
- question_name: PowerShell Script
type: textarea
variable: ps_script
default: "Get-Service | Where-Object -FilterScript {$_.Status -eq 'running'} | Select-Object -Property 'Name'"
@@ -163,7 +163,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -171,7 +171,7 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- question_name: Service state to query?
type: multiplechoice
@@ -191,7 +191,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -199,7 +199,7 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- name: "WINDOWS / AD /Create Domain"
@@ -211,7 +211,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''
@@ -219,7 +219,7 @@ controller_templates:
spec:
- question_name: Server Name or Pattern
type: text
variable: HOSTS
variable: _hosts
required: false
- name: "WINDOWS / AD / New User"
@@ -231,7 +231,7 @@ controller_templates:
notification_templates_success: Telemetry
notification_templates_error: Telemetry
credentials:
- "Workshop Credential"
- "Workshop Credential"
survey_enabled: true
survey:
name: ''

View File

@@ -1,32 +0,0 @@
---
- name: open a change request
hosts: student1-ansible-1
vars:
change_request:
severity: 2
priority: 2
description: Automated Provisioning
justification: Ansible Triggered
implementation_plan: Updated by Red Hat AAP
risk_impact_analysis: Changes are made automatically based on approved changes
test_plan: Run synthetic validation tests post-deployment
short_description: Automated Provisioning
tasks:
- name: Create a change request
servicenow.itsm.change_request:
instance:
host: "https://{{ snow_instance }}.service-now.com"
username: "{{ snow_username }}"
password: "{{ snow_password }}"
type: standard
state: new
requested_by: admin
short_description: "{{ change_request.short_description }}"
description: "{{ change_request.description }}"
priority: moderate
risk: low
impact: low
register: new_incident
- debug:
var: new_incident.record.number

View File

@@ -1,27 +1,28 @@
---
- name: Chocolatey install multiple
hosts: "{{ HOSTS | default('windows') }}"
hosts: "{{ _hosts | default('os_windows') }}"
gather_facts: false
vars:
choco_packages:
- name: nodejs
- name: python
tasks:
- name: Install specific versions of packages sequentially
win_chocolatey:
name: "{{ item.name }}"
state: latest
loop: "{{ choco_packages }}"
- name: Install specific versions of packages sequentially
chocolatey.chocolatey.win_chocolatey:
name: "{{ item.name }}"
state: installed
loop: "{{ choco_packages }}"
- name: Check python version
win_command: python --version
register: check_python_version
changed_when: false
- name: Check python version
ansible.windows.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
- name: Check nodejs version
ansible.windows.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] }}
- name: Print message
ansible.builtin.debug:
msg: Python Version is {{ check_python_version.stdout_lines[0] }} and NodeJS version is {{ check_node_version.stdout_lines[0] }}

View File

@@ -1,9 +1,9 @@
---
- name: Chocolatey install specific
hosts: "{{ HOSTS | default('windows') }}"
hosts: "{{ _hosts | default('os_windows') }}"
gather_facts: false
tasks:
- name: Install choco package with specific version
win_chocolatey:
name: "{{ package_name }}"
- name: Install choco package with specific version
chocolatey.chocolatey.win_chocolatey:
name: "{{ package_name }}"