Skip to content

Commit

Permalink
Version 0.0.4
Browse files Browse the repository at this point in the history
add scheduled_tasks role
  • Loading branch information
sbaerlocher authored May 8, 2020
2 parents c0dda14 + de22ec9 commit a0dafae
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ and [human-readable changelog](https://keepachangelog.com/en/1.0.0/).

## master

## 0.0.4

### Added

- Add role scheduled_tasks

## 0.0.3

### Fixed
Expand Down
48 changes: 26 additions & 22 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@
nav: [
{
title: 'Home',
link: '/'
link: '/',
},
{
title: 'GitHub',
link: 'https://github.com/sbaerlocher/ansible.windows'
link: 'https://github.com/sbaerlocher/ansible.windows',
},
{
title: 'Ansible Galaxy',
link: 'https://galaxy.ansible.com/sbaerlocher/windows'
}
link: 'https://galaxy.ansible.com/sbaerlocher/windows',
},
],
overrides: {
'/': {
language: 'English' // Used by the language dropdown menu in the sidebar
}
language: 'English', // Used by the language dropdown menu in the sidebar
},
},
// Use `versions` option to add a version selector
// In the sidebar
versions: {
Latest: {
link: '/'
}
link: '/',
},
},
sidebar: [
// A sidebar item, with child links
Expand All @@ -54,52 +54,56 @@
children: [
{
title: 'Defender',
link: '/roles/defender/README'
link: '/roles/defender/README',
},
{
title: 'Directories',
link: '/roles/directories/README'
link: '/roles/directories/README',
},
{
title: 'Disks',
link: '/roles/disks/README'
link: '/roles/disks/README',
},
{
title: 'Local Administrators',
link: '/roles/local_administrators/README'
link: '/roles/local_administrators/README',
},
{
title: 'Membership',
link: '/roles/membership/README'
link: '/roles/membership/README',
},
{
title: 'OneDrive',
link: '/roles/onedrive/README'
link: '/roles/onedrive/README',
},
{
title: 'Optional Features',
link: '/roles/optional_features/README'
link: '/roles/optional_features/README',
},
{
title: 'Power Plan',
link: '/roles/power_plan/README'
link: '/roles/power_plan/README',
},
{
title: 'Scheduled Tasks',
link: '/roles/scheduled_tasks/README',
},
{
title: 'Remote Desktop',
link: '/roles/remote_desktop/README'
link: '/roles/remote_desktop/README',
},
{
title: 'Startlayout',
link: '/roles/startlayout/README'
}
]
}
link: '/roles/startlayout/README',
},
],
},
],
footer: `
<div style="border-top:1px solid var(--border-color);padding-top:30px;margin: 40px 0;color:#999999;">
&copy; ${new Date().getFullYear()} sbaerlocher. Released under MIT license.
</div>
`
`,
});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: 'sbaerlocher'
name: 'windows'
version: 0.0.3
version: 0.0.4
readme: README.md
authors:
- 'Simon Baerlocher (https://sbaerlocher.ch)'
Expand Down
39 changes: 39 additions & 0 deletions roles/scheduled_tasks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Ansible Role: scheduled_tasks

## Description

You can specify a list of Schedules Tasks to be created under Windows.

## Role Variables

### scheduled_tasks

List of Schedules Tasks, the single parameters can be taken from the [documentation](https://docs.ansible.com/ansible/latest/modules/win_scheduled_task_module.html) of Ansible.

#### Example

```yml
scheduled_tasks:
- name: 'Chocolatey Packages upgrade'
description: 'chocolatey upgrade all Packages evry Day at 12:00'
actions:
- path: powershell.exe
working_directory: 'C:\Support\scripts\'
arguments: '-ExecutionPolicy Bypass -File "C:\Support\scripts\Choco-Update.ps1"'
triggers:
- type: daily
start_boundary: '2017-10-09T12:00:00'
username: SYSTEM
state: present
enabled: true
```
## Example Playbook
```yml
- hosts: all
collections:
- sbaerlocher.windows
roles:
- scheduled_tasks
```
25 changes: 25 additions & 0 deletions roles/scheduled_tasks/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# defaults file for scheduled_tasks

# List of Schedules Tasks, the single parameters
# can be taken from the documentation of Ansible.
# https://docs.ansible.com/ansible/latest/modules/win_scheduled_task_module.html
#
# Example:
#
# scheduled_tasks:
# - name: 'Chocolatey Packages upgrade'
# description: 'chocolatey upgrade all Packages evry Day at 12:00'
# actions:
# - path: powershell.exe
# working_directory: 'C:\Support\scripts\'
# arguments: '-ExecutionPolicy Bypass -File "C:\Support\scripts\Choco-Update.ps1"'
# triggers:
# - type: daily
# start_boundary: '2017-10-09T12:00:00'
# username: SYSTEM
# state: present
# enabled: true
#

# scheduled_tasks:
16 changes: 16 additions & 0 deletions roles/scheduled_tasks/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
galaxy_info:
author: Simon Baerlocher (https://sbaerlocher.ch)
description: Create scheduled tasks.
license: MIT
min_ansible_version: 2.9
platforms:
- name: Windows
versions:
- all

galaxy_tags:
- windows
- scheduled_tasks

dependencies: []
21 changes: 21 additions & 0 deletions roles/scheduled_tasks/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: 'geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest'
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
5 changes: 5 additions & 0 deletions roles/scheduled_tasks/molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Converge
hosts: all
roles:
- role: sbaerlocher.windows.scheduled_tasks
10 changes: 10 additions & 0 deletions roles/scheduled_tasks/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# tasks file for scheduled_tasks

- name: 'include scheduled tasks'
include_tasks: 'scheduled_task.yml'
loop: '{{ scheduled_tasks }}'
loop_control:
loop_var: scheduled_task
tags:
- configuration
38 changes: 38 additions & 0 deletions roles/scheduled_tasks/tasks/scheduled_task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# tasks file for scheduled_tasks

- name: 'Create {{ scheduled_task.name }} scheduled task'
win_scheduled_task:
name: '{{ scheduled_task.name }}'
description: '{{ scheduled_task.description | default(omit) }}'
actions: '{{ scheduled_task.actions }}'
allow_demand_start: '{{ scheduled_task.allow_demand_start | default(omit) }}'
allow_hard_terminate: '{{ scheduled_task.allow_hard_terminate | default(omit) }}'
author: '{{ scheduled_task.author | default(omit) }}'
compatibility: '{{ scheduled_task.compatibility | default(omit) }}'
date: '{{ scheduled_task.date | default(omit) }}'
delete_expired_task_after: '{{ scheduled_task.delete_expired_task_after | default(omit) }}'
disallow_start_if_on_batteries: '{{ scheduled_task.disallow_start_if_on_batteries | default(omit) }}'
display_name: '{{ scheduled_task.display_name | default(omit) }}'
enabled: '{{ scheduled_task.enabled | default(omit) }}'
execution_time_limit: '{{ scheduled_task.execution_time_limit | default(omit) }}'
group: '{{ scheduled_task.group | default(omit) }}'
hidden: '{{ scheduled_task.delete_expired_task_after | default(omit) }}'
logon_type: '{{ scheduled_task.logon_type | default(omit) }}'
multiple_instances: '{{ scheduled_task.multiple_instances | default(omit) }}'
password: '{{ scheduled_task.password| default(omit) }}'
path: '{{ scheduled_task.path | default(omit) }}'
priority: '{{ scheduled_task.priority | default(omit) }}'
restart_count: '{{ scheduled_task.restart_count | default(omit) }}'
run_level: '{{ scheduled_task.run_level | default(omit) }}'
run_only_if_idle: '{{ scheduled_task.run_only_if_idle | default(omit) }}'
run_only_if_network_available: '{{ scheduled_task.run_only_if_network_available | default(omit) }}'
source: '{{ scheduled_task.source | default(omit) }}'
start_when_available: '{{ scheduled_task.start_when_available | default(omit) }}'
state: '{{ scheduled_task.state | default(omit) }}'
stop_if_going_on_batteries: '{{ scheduled_task.stop_if_going_on_batteries | default(omit) }}'
triggers: '{{ scheduled_task.triggers | default(omit) }}'
update_password: '{{ scheduled_task.update_password | default(omit) }}'
username: '{{ scheduled_task.username | default(omit) }}'
version: '{{ scheduled_task.version | default(omit) }}'
wake_to_run: '{{ scheduled_task.wake_to_run | default(omit) }}'

0 comments on commit a0dafae

Please sign in to comment.