chore: Better lint compliance

This commit is contained in:
Laur Ivan 2023-04-30 13:07:53 +02:00
parent a412940e75
commit f417e1828d
9 changed files with 60 additions and 58 deletions

View File

@ -23,7 +23,7 @@ You need a machine with docker and docker-compose installed.
```yml
- hosts: servers
roles:
- 'laurivan.{{ cookiecutter.app_name | replace('_',' ') | title }}'
- 'laurivan.{{ cookiecutter.app_name | replace('_',' ') }}'
```
## License

View File

@ -22,5 +22,3 @@
# Documentation
{{ cookiecutter.app_name }}_documentation_link: "{{ cookiecutter.documentation_URL }}"

View File

@ -3,7 +3,7 @@
galaxy_info:
author: {{ cookiecutter.author }}
namespace: {{ cookiecutter.namespace }}
{% if cookiecutter.company != "" %}company: {{ cookiecutter.company }}{% endif %}
{% if cookiecutter.company != "" %} company: {{ cookiecutter.company }}{% endif %}
role_name: {{ cookiecutter.app_name }}
description: {{ cookiecutter.app_name | replace('_',' ') | title }} Role
min_ansible_version: "{{ cookiecutter.min_ansible_version }}"

View File

@ -3,21 +3,25 @@
hosts: all
gather_facts: true
tasks:
- name: Check if the docker-compose file exists.
- name: "{{ cookiecutter.app_name | upper }} | Load the defaults."
ansible.builtin.include_vars:
dir: "../../defaults"
- name: "{{ cookiecutter.app_name | upper }} | Check if the docker-compose file exists."
ansible.builtin.stat:
path: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/docker-compose.yml"
register: docker_compose_file
register: "docker_compose_file"
- name: Remove docker-compose.
- name: "{{ cookiecutter.app_name | upper }} | Remove docker-compose."
community.docker.docker_compose:
project_src: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/"
project_src: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/"
build: false
state: absent
when: docker_compose_file.stat.exists
when: "docker_compose_file.stat.exists"
become: false
- name: Remove the docker-compose file
- name: "{{ cookiecutter.app_name | upper }} | Remove the docker-compose file"
ansible.builtin.file:
path: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/docker-compose.yml"
state: absent
when: docker_compose_file.stat.exists
path: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/docker-compose.yml"
state: "absent"
when: "docker_compose_file.stat.exists"

View File

@ -1,5 +1,5 @@
---
- name: Converge
hosts: {{ cookiecutter.app_name }}_group
- name: "{{ cookiecutter.app_name | upper }} | Converge"
hosts: "{{ cookiecutter.app_name }}_group"
roles:
- role: "{{cookiecutter.namespace}}.{{ cookiecutter.app_name }}"

View File

@ -1,27 +1,27 @@
---
- name: Destroy
hosts: localhost
connection: local
- name: "{{ cookiecutter.app_name | upper }} | Destroy"
hosts: "localhost"
connection: "local"
gather_facts: false
no_log: "{% raw %}{{ molecule_no_log }}{% endraw %}"
tasks:
# Developer must implement.
- name: Remove the docker image
- name: "{{ cookiecutter.app_name | upper }} | Remove the docker image"
community.docker.docker_container:
name: {{ cookiecutter.app_name }}
state: absent
name: "{{ cookiecutter.app_name }}"
state: "absent"
# Mandatory configuration for Molecule to function.
- name: Populate instance config
- name: "{{ cookiecutter.app_name | upper }} | Populate instance config"
ansible.builtin.set_fact:
instance_conf: {}
- name: Dump instance config
- name: "{{ cookiecutter.app_name | upper }} | Dump instance config"
ansible.builtin.copy:
content: |
# Molecule managed
{% raw %}{{ instance_conf | to_json | from_json | to_yaml }}{% endraw %}
dest: "{% raw %}{{ molecule_instance_config }}{% endraw %}"
mode: 0600
when: server.changed | default(false) | bool
when: "server.changed | default(false) | bool"

View File

@ -1,38 +1,38 @@
---
- name: Setup the test machine
hosts: {{ cookiecutter.app_name }}
- name: "{{ cookiecutter.app_name | upper }} | Setup the test machine"
hosts: "{{ cookiecutter.app_name }}"
tasks:
- name: Check if /var/run/docker.sock already exists
- name: "{{ cookiecutter.app_name | upper }} | Check if /var/run/docker.sock already exists"
ansible.builtin.stat:
path: "/var/run/docker.sock"
register: docker_sock_stat
register: "docker_sock_stat"
- name: Create docker.sock
- name: "{{ cookiecutter.app_name | upper }} | Create docker.sock"
ansible.builtin.raw: touch /var/run/docker.sock
become: true
changed_when: false
when: not docker_sock_stat.stat.exists
when: "not docker_sock_stat.stat.exists"
- name: Move docker.sock from tmp
- name: "{{ cookiecutter.app_name | upper }} | Move docker.sock from tmp"
ansible.builtin.raw: >
mount --move /tmp/docker_mounted.sock /var/run/docker.sock
become: true
changed_when: false
when: not docker_sock_stat.stat.exists
when: "not docker_sock_stat.stat.exists"
- name: Update apt cache.
- name: "{{ cookiecutter.app_name | upper }} | Update apt cache."
ansible.builtin.apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
when: "ansible_os_family == 'Debian'"
- name: Install python requests
- name: "{{ cookiecutter.app_name | upper }} | Install python requests"
ansible.builtin.pip:
name:
- requests
- docker
- docker-compose
- "requests"
- "docker"
- "docker-compose"
- name: Install docker
- name: "{{ cookiecutter.app_name | upper }} | Install docker"
vars:
docker_service_manage: false
ansible.builtin.include_role:
name: geerlingguy.docker
name: "geerlingguy.docker"

View File

@ -1,4 +1,4 @@
---
roles:
- geerlingguy.docker
- "geerlingguy.docker"
collections: []

View File

@ -5,54 +5,54 @@
- name: Verify {{ cookiecutter.app_name | replace('_',' ') }}
hosts:
- {{ cookiecutter.app_name }}
- "{{ cookiecutter.app_name }}"
become: true
vars:
goss_version: v0.3.16
goss_arch: amd64
goss_dst: /usr/local/bin/goss
goss_sha256sum: 827e354b48f93bce933f5efcd1f00dc82569c42a179cf2d384b040d8a80bfbfb
goss_version: "v0.3.16"
goss_arch: "amd64"
goss_dst: "/usr/local/bin/goss"
goss_sha256sum: "827e354b48f93bce933f5efcd1f00dc82569c42a179cf2d384b040d8a80bfbfb"
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{% raw %}{{{% endraw %} goss_version {% raw %}}}{% endraw %}/goss-linux-{% raw %}{{{% endraw %} goss_arch {% raw %}}}{% endraw %}"
goss_test_directory: /tmp
goss_format: documentation
goss_test_directory:" /tmp"
goss_format: "documentation"
vars_files:
- ../../defaults/main.yml
tasks:
- name: Download and install Goss
- name: "{{ cookiecutter.app_name | upper }} | Download and install Goss"
get_url:
url: "{% raw %}{{{% endraw %} goss_url {% raw %}}}{% endraw %}"
dest: "{% raw %}{{{% endraw %} goss_dst {% raw %}}}{% endraw %}"
checksum: "sha256{% raw %}:{{{% endraw %} goss_sha256sum {% raw %}}}{% endraw %}"
mode: 0755
register: download_goss
until: download_goss is succeeded
register: "download_goss"
until: "download_goss is succeeded"
retries: 3
- name: Copy Goss tests to remote
- name: "{{ cookiecutter.app_name | upper }} | Copy Goss tests to remote"
template:
src: "{% raw %}{{{% endraw %} item {% raw %}}}{% endraw %}"
dest: "{% raw %}{{{% endraw %} goss_test_directory {% raw %}}}{% endraw %}/{% raw %}{{{% endraw %} item | basename {% raw %}}}{% endraw %}"
with_fileglob:
- "tests/test_*.yml"
- name: Register test files
- name: "{{ cookiecutter.app_name | upper }} | Register test files"
shell: "ls {% raw %}{{{% endraw %} goss_test_directory {% raw %}}}{% endraw %}/test_*.yml"
register: test_files
register: "test_files"
- name: Execute Goss tests
- name: "{{ cookiecutter.app_name | upper }} | Execute Goss tests"
command: "{% raw %}{{{% endraw %} goss_dst {% raw %}}}{% endraw %} -g {% raw %}{{{% endraw %} item {% raw %}}}{% endraw %} validate --format {% raw %}{{{% endraw %} goss_format {% raw %}}}{% endraw %}"
register: test_results
register: "test_results"
with_items: "{% raw %}{{{% endraw %} test_files.stdout_lines {% raw %}}}{% endraw %}"
ignore_errors: true
- name: Display details about the Goss results
- name: "{{ cookiecutter.app_name | upper }} | Display details about the Goss results"
debug:
msg: "{% raw %}{{{% endraw %} item.stdout_lines {% raw %}}}{% endraw %}"
with_items: "{% raw %}{{{% endraw %} test_results.results {% raw %}}}{% endraw %}"
- name: Fail when tests fail
- name: "{{ cookiecutter.app_name | upper }} | Fail when tests fail"
fail:
msg: "Goss failed to validate"
when: item.rc != 0