chore: Better lint compliance
This commit is contained in:
parent
a412940e75
commit
f417e1828d
@ -23,7 +23,7 @@ You need a machine with docker and docker-compose installed.
|
|||||||
```yml
|
```yml
|
||||||
- hosts: servers
|
- hosts: servers
|
||||||
roles:
|
roles:
|
||||||
- 'laurivan.{{ cookiecutter.app_name | replace('_',' ') | title }}'
|
- 'laurivan.{{ cookiecutter.app_name | replace('_',' ') }}'
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -22,5 +22,3 @@
|
|||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
{{ cookiecutter.app_name }}_documentation_link: "{{ cookiecutter.documentation_URL }}"
|
{{ cookiecutter.app_name }}_documentation_link: "{{ cookiecutter.documentation_URL }}"
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,21 +3,25 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
tasks:
|
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:
|
ansible.builtin.stat:
|
||||||
path: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/docker-compose.yml"
|
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:
|
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
|
build: false
|
||||||
state: absent
|
state: absent
|
||||||
when: docker_compose_file.stat.exists
|
when: "docker_compose_file.stat.exists"
|
||||||
become: false
|
become: false
|
||||||
|
|
||||||
- name: Remove the docker-compose file
|
- name: "{{ cookiecutter.app_name | upper }} | Remove the docker-compose file"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/docker-compose.yml"
|
path: "{% raw %}{{{% endraw %} {{ cookiecutter.app_name }}_config_path | expanduser | realpath {% raw %}}}{% endraw %}/docker-compose.yml"
|
||||||
state: absent
|
state: "absent"
|
||||||
when: docker_compose_file.stat.exists
|
when: "docker_compose_file.stat.exists"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Converge
|
- name: "{{ cookiecutter.app_name | upper }} | Converge"
|
||||||
hosts: {{ cookiecutter.app_name }}_group
|
hosts: "{{ cookiecutter.app_name }}_group"
|
||||||
roles:
|
roles:
|
||||||
- role: "{{cookiecutter.namespace}}.{{ cookiecutter.app_name }}"
|
- role: "{{cookiecutter.namespace}}.{{ cookiecutter.app_name }}"
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
---
|
---
|
||||||
- name: Destroy
|
- name: "{{ cookiecutter.app_name | upper }} | Destroy"
|
||||||
hosts: localhost
|
hosts: "localhost"
|
||||||
connection: local
|
connection: "local"
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
no_log: "{% raw %}{{ molecule_no_log }}{% endraw %}"
|
no_log: "{% raw %}{{ molecule_no_log }}{% endraw %}"
|
||||||
tasks:
|
tasks:
|
||||||
# Developer must implement.
|
# Developer must implement.
|
||||||
- name: Remove the docker image
|
- name: "{{ cookiecutter.app_name | upper }} | Remove the docker image"
|
||||||
community.docker.docker_container:
|
community.docker.docker_container:
|
||||||
name: {{ cookiecutter.app_name }}
|
name: "{{ cookiecutter.app_name }}"
|
||||||
state: absent
|
state: "absent"
|
||||||
|
|
||||||
# Mandatory configuration for Molecule to function.
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
- name: Populate instance config
|
- name: "{{ cookiecutter.app_name | upper }} | Populate instance config"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
instance_conf: {}
|
instance_conf: {}
|
||||||
|
|
||||||
- name: Dump instance config
|
- name: "{{ cookiecutter.app_name | upper }} | Dump instance config"
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: |
|
content: |
|
||||||
# Molecule managed
|
# Molecule managed
|
||||||
{% raw %}{{ instance_conf | to_json | from_json | to_yaml }}{% endraw %}
|
{% raw %}{{ instance_conf | to_json | from_json | to_yaml }}{% endraw %}
|
||||||
dest: "{% raw %}{{ molecule_instance_config }}{% endraw %}"
|
dest: "{% raw %}{{ molecule_instance_config }}{% endraw %}"
|
||||||
mode: 0600
|
mode: 0600
|
||||||
when: server.changed | default(false) | bool
|
when: "server.changed | default(false) | bool"
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
---
|
---
|
||||||
- name: Setup the test machine
|
- name: "{{ cookiecutter.app_name | upper }} | Setup the test machine"
|
||||||
hosts: {{ cookiecutter.app_name }}
|
hosts: "{{ cookiecutter.app_name }}"
|
||||||
tasks:
|
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:
|
ansible.builtin.stat:
|
||||||
path: "/var/run/docker.sock"
|
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
|
ansible.builtin.raw: touch /var/run/docker.sock
|
||||||
become: true
|
become: true
|
||||||
changed_when: false
|
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: >
|
ansible.builtin.raw: >
|
||||||
mount --move /tmp/docker_mounted.sock /var/run/docker.sock
|
mount --move /tmp/docker_mounted.sock /var/run/docker.sock
|
||||||
become: true
|
become: true
|
||||||
changed_when: false
|
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
|
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:
|
ansible.builtin.pip:
|
||||||
name:
|
name:
|
||||||
- requests
|
- "requests"
|
||||||
- docker
|
- "docker"
|
||||||
- docker-compose
|
- "docker-compose"
|
||||||
|
|
||||||
- name: Install docker
|
- name: "{{ cookiecutter.app_name | upper }} | Install docker"
|
||||||
vars:
|
vars:
|
||||||
docker_service_manage: false
|
docker_service_manage: false
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: geerlingguy.docker
|
name: "geerlingguy.docker"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
roles:
|
roles:
|
||||||
- geerlingguy.docker
|
- "geerlingguy.docker"
|
||||||
collections: []
|
collections: []
|
||||||
|
@ -5,54 +5,54 @@
|
|||||||
|
|
||||||
- name: Verify {{ cookiecutter.app_name | replace('_',' ') }}
|
- name: Verify {{ cookiecutter.app_name | replace('_',' ') }}
|
||||||
hosts:
|
hosts:
|
||||||
- {{ cookiecutter.app_name }}
|
- "{{ cookiecutter.app_name }}"
|
||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
goss_version: v0.3.16
|
goss_version: "v0.3.16"
|
||||||
goss_arch: amd64
|
goss_arch: "amd64"
|
||||||
goss_dst: /usr/local/bin/goss
|
goss_dst: "/usr/local/bin/goss"
|
||||||
goss_sha256sum: 827e354b48f93bce933f5efcd1f00dc82569c42a179cf2d384b040d8a80bfbfb
|
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_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_test_directory:" /tmp"
|
||||||
goss_format: documentation
|
goss_format: "documentation"
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- ../../defaults/main.yml
|
- ../../defaults/main.yml
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Download and install Goss
|
- name: "{{ cookiecutter.app_name | upper }} | Download and install Goss"
|
||||||
get_url:
|
get_url:
|
||||||
url: "{% raw %}{{{% endraw %} goss_url {% raw %}}}{% endraw %}"
|
url: "{% raw %}{{{% endraw %} goss_url {% raw %}}}{% endraw %}"
|
||||||
dest: "{% raw %}{{{% endraw %} goss_dst {% raw %}}}{% endraw %}"
|
dest: "{% raw %}{{{% endraw %} goss_dst {% raw %}}}{% endraw %}"
|
||||||
checksum: "sha256{% raw %}:{{{% endraw %} goss_sha256sum {% raw %}}}{% endraw %}"
|
checksum: "sha256{% raw %}:{{{% endraw %} goss_sha256sum {% raw %}}}{% endraw %}"
|
||||||
mode: 0755
|
mode: 0755
|
||||||
register: download_goss
|
register: "download_goss"
|
||||||
until: download_goss is succeeded
|
until: "download_goss is succeeded"
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
- name: Copy Goss tests to remote
|
- name: "{{ cookiecutter.app_name | upper }} | Copy Goss tests to remote"
|
||||||
template:
|
template:
|
||||||
src: "{% raw %}{{{% endraw %} item {% raw %}}}{% endraw %}"
|
src: "{% raw %}{{{% endraw %} item {% raw %}}}{% endraw %}"
|
||||||
dest: "{% raw %}{{{% endraw %} goss_test_directory {% raw %}}}{% endraw %}/{% raw %}{{{% endraw %} item | basename {% raw %}}}{% endraw %}"
|
dest: "{% raw %}{{{% endraw %} goss_test_directory {% raw %}}}{% endraw %}/{% raw %}{{{% endraw %} item | basename {% raw %}}}{% endraw %}"
|
||||||
with_fileglob:
|
with_fileglob:
|
||||||
- "tests/test_*.yml"
|
- "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"
|
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 %}"
|
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 %}"
|
with_items: "{% raw %}{{{% endraw %} test_files.stdout_lines {% raw %}}}{% endraw %}"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Display details about the Goss results
|
- name: "{{ cookiecutter.app_name | upper }} | Display details about the Goss results"
|
||||||
debug:
|
debug:
|
||||||
msg: "{% raw %}{{{% endraw %} item.stdout_lines {% raw %}}}{% endraw %}"
|
msg: "{% raw %}{{{% endraw %} item.stdout_lines {% raw %}}}{% endraw %}"
|
||||||
with_items: "{% raw %}{{{% endraw %} test_results.results {% 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:
|
fail:
|
||||||
msg: "Goss failed to validate"
|
msg: "Goss failed to validate"
|
||||||
when: item.rc != 0
|
when: item.rc != 0
|
||||||
|
Loading…
Reference in New Issue
Block a user