Skip to content

Commit

Permalink
Merge branch 'master' into fixed/import-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaerlocher authored May 4, 2020
2 parents 9d3345a + 9dfe189 commit 441559d
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 19 deletions.
41 changes: 22 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Changelog

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
and [human-readable changelog](https://keepachangelog.com/en/1.0.0/).

## master

## 0.0.2

### Fixed

- Fixed import lint

## 0.0.1

### Added

- Initial develop
- Initial docs
# Changelog

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
and [human-readable changelog](https://keepachangelog.com/en/1.0.0/).

## master

## 0.0.2

### Fixed

- Fixed import lint
### Added

- Add role files

## 0.0.1

### Added

- Initial develop
- Initial docs
1 change: 1 addition & 0 deletions roles/directories/tasks/directories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
loop: '{{ directory.subdirectories }}'
loop_control:
loop_var: subdirectories
when: directory.subdirectories is defined
tags:
- configuration
32 changes: 32 additions & 0 deletions roles/files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Ansible Role: files

## Description

Downloads a file or creates one from a structure.

## Role Variables

### Files

List of configuration dictionary defining the content.

```yml
files:
- type: content
path: "c:\\support"
name: 'test'
extension: json
content:
HEALTHCHECK_URL: 'https://healthchecks.itigo.tech'
HEALTCHECKS_CHOCO_API_KEY: hallo
```
## Example Playbook
```yml
- hosts: all
collections:
- sbaerlocher.windows
roles:
- files
```
25 changes: 25 additions & 0 deletions roles/files/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# defaults file for files

# List of configuration dictionary defining the content.
# The following properties are supported:
# type content | url [required]
# path [required] Path where the file should be saved.
# name [required] File name.
# extension [required] File extension the one that should have the file.
# content [optional] List or dictionary of key/value pairs, when content.
# url [optional] Url from where the file can be downloaded.
#
# Example:
#
# files:
# - type: content
# path: "c:\\support"
# name: 'test'
# extension: json
# content:
# HEALTHCHECK_URL: 'https://healthchecks.itigo.tech'
# HEALTCHECKS_CHOCO_API_KEY: hallo
#

# files:
16 changes: 16 additions & 0 deletions roles/files/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: Downloads a file or creates one from a structure.
license: MIT
min_ansible_version: 2.9
platforms:
- name: Windows
versions:
- all

galaxy_tags:
- windows
- files

dependencies: []
21 changes: 21 additions & 0 deletions roles/files/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/files/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.files
8 changes: 8 additions & 0 deletions roles/files/tasks/content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# tasks file for files

- name: "Create {{ file.path }}\\{{ file.name }}.{{ file.extension }}"
win_copy:
dest: "{{ file.path }}\\{{ file.name }}.{{ file.extension }}"
content: '{{ file.content | to_nice_json }}'
state: "{{ file.state | default('present') }}"
22 changes: 22 additions & 0 deletions roles/files/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# tasks file for files

- name: 'include directories role'
include_role:
name: directories
vars:
directories:
- main: '{{ file.path }}'
loop: '{{ files }}'
loop_control:
loop_var: file
tags:
- configuration

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

- name: "Create {{ file.path }}\\{{ file.name }}.{{ file.extension }}"
win_get_url:
url: '{{ file.url }}'
dest: '{{ file.path }}\\{{ file.name }}.{{ file.extension }}'
when: item.state | default("present") == "present"

- name: "Absent {{ file.path }}\\{{ file.name }}.{{ file.extension }}"
win_file:
path: "{{ file.path }}\\{{ file.name }}.{{ file.extension }}"
state: absent
when:
- ("state" in item.keys())
- item.state == "absent"

0 comments on commit 441559d

Please sign in to comment.