Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yamllint issue #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
venv
.tox/
*.pyc
venv
13 changes: 13 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends: default

ignore: |
.tox

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
7 changes: 4 additions & 3 deletions roles/init/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
- name: Ensure 'parent' variable is set (see README.md)
assert:
that: parent is defined

- name: Ensure 'structure' variable is set and one of 'role' or 'collection' (see README.md)
- name: Ensure 'structure' variable is 'role' or 'collection' (see README.md)
assert:
that: structure is defined and structure in ['role', 'collection']

Expand Down Expand Up @@ -34,12 +35,12 @@
src: "{{ rm['LICENSE'] | default('gpl-3.0.txt') }}"
dest: "{{ parent }}/LICENSE.txt"

- name: Ensure the 'collection_org' is set when 'structure' is set to collection
- name: Ensure the 'collection_org' is set when 'structure' is collection
assert:
that: collection_org is defined
when: structure == 'collection'

- name: Ensure the 'collection_name' is set when 'structure' is set to collection
- name: Ensure the 'collection_name' is set when 'structure' is collection
assert:
that: collection_name is defined
when: structure == 'collection'
25 changes: 13 additions & 12 deletions roles/init/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
directories:
collection:
- plugins/modules
- plugins/module_utils
- plugins/filter
- plugins/action
- plugins/inventory
- playbooks
- docs
- roles
role:
- library
- module_utils
collection:
- plugins/modules
- plugins/module_utils
- plugins/filter
- plugins/action
- plugins/inventory
- playbooks
- docs
- roles
role:
- library
- module_utils
2 changes: 1 addition & 1 deletion roles/resource_module/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

---
- name: "Create the resource module directory structure"
file:
path: "{{ parent_directory }}/{{ item }}"
Expand Down
1 change: 1 addition & 0 deletions roles/resource_module/tasks/template.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Check to see if the file exists
stat:
path: "{{ parent_directory}}/{{ template['destination'] }}"
Expand Down
91 changes: 46 additions & 45 deletions roles/resource_module/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# basic vars to make the templates cleaner
network_os: "{{ rm['NETWORK_OS'] }}"
resource: "{{ rm['RESOURCE'] }}"
Expand Down Expand Up @@ -25,51 +26,51 @@ import_path: "{{ import_paths[structure] }}.network"

# all the directories that need to be built
resource_module_directories:
- "{{ module_directory }}"
- module_utils
- module_utils/network
- module_utils/network/{{ network_os }}
- module_utils/network/{{ network_os }}/argspec
- module_utils/network/{{ network_os }}/argspec/facts
- module_utils/network/{{ network_os }}/argspec/{{ resource }}
- module_utils/network/{{ network_os }}/config
- module_utils/network/{{ network_os }}/config/{{ resource }}
- module_utils/network/{{ network_os }}/facts
- module_utils/network/{{ network_os }}/facts/{{ resource }}
- module_utils/network/{{ network_os }}/utils
- "{{ module_directory }}"
- module_utils
- module_utils/network
- module_utils/network/{{ network_os }}
- module_utils/network/{{ network_os }}/argspec
- module_utils/network/{{ network_os }}/argspec/facts
- module_utils/network/{{ network_os }}/argspec/{{ resource }}
- module_utils/network/{{ network_os }}/config
- module_utils/network/{{ network_os }}/config/{{ resource }}
- module_utils/network/{{ network_os }}/facts
- module_utils/network/{{ network_os }}/facts/{{ resource }}
- module_utils/network/{{ network_os }}/utils

# each of the files to be templated
resource_module_templates:
- source: README.md.j2
destination: "{{ parent }}/README.md"
overwrite: False
- source: module_directory/network_os/network_os_resource.py.j2
destination: "{{ parent_directory }}/{{ module_directory }}/{{ network_os }}_{{ resource }}.py"
overwrite: True
- source: module_directory/network_os/network_os_facts.py.j2
destination: "{{ parent_directory }}/{{ module_directory }}/{{ network_os }}_facts.py"
overwrite: False
- source: module_utils/network_os/argspec/facts/facts.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/argspec/facts/facts.py"
overwrite: False
- source: module_utils/network_os/argspec/resource/resource.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/argspec/{{ resource }}/{{ resource }}.py"
overwrite: True
- source: module_utils/network_os/config/base.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/config/base.py"
overwrite: False
- source: module_utils/network_os/config/resource/resource.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/config/{{ resource }}/{{ resource }}.py"
overwrite: False
- source: module_utils/network_os/facts/base.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/facts/base.py"
overwrite: False
- source: module_utils/network_os/facts/facts.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/facts/facts.py"
overwrite: False
- source: module_utils/network_os/facts/resource/resource.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/facts/{{ resource }}/{{ resource }}.py"
overwrite: False
- source: module_utils/network_os/utils/utils.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/utils/utils.py"
overwrite: False
- source: README.md.j2
destination: "{{ parent }}/README.md"
overwrite: false
- source: module_directory/network_os/network_os_resource.py.j2
destination: "{{ parent_directory }}/{{ module_directory }}/{{ network_os }}_{{ resource }}.py"
overwrite: true
- source: module_directory/network_os/network_os_facts.py.j2
destination: "{{ parent_directory }}/{{ module_directory }}/{{ network_os }}_facts.py"
overwrite: false
- source: module_utils/network_os/argspec/facts/facts.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/argspec/facts/facts.py"
overwrite: false
- source: module_utils/network_os/argspec/resource/resource.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/argspec/{{ resource }}/{{ resource }}.py"
overwrite: true
- source: module_utils/network_os/config/base.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/config/base.py"
overwrite: false
- source: module_utils/network_os/config/resource/resource.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/config/{{ resource }}/{{ resource }}.py"
overwrite: false
- source: module_utils/network_os/facts/base.py.j2
destination: "{{ parent_directory }}/module_utils/network/{{ network_os }}/facts/base.py"
overwrite: false
- source: module_utils/network_os/facts/facts.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/facts/facts.py"
overwrite: false
- source: module_utils/network_os/facts/resource/resource.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/facts/{{ resource }}/{{ resource }}.py"
overwrite: false
- source: module_utils/network_os/utils/utils.py.j2
destination: "{{ parent_directory}}/module_utils/network/{{ network_os }}/utils/utils.py"
overwrite: false
7 changes: 4 additions & 3 deletions site.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
gather_facts: no
gather_facts: false
roles:
- init
- resource_module
- init
- resource_module
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yamllint
3 changes: 2 additions & 1 deletion tests/inventory.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
all:
children:
eos:
Expand All @@ -9,7 +10,7 @@ all:
ansible_user: admin
ansible_connection: network_cli
ansible_password: password
ansible_become: True
ansible_become: true
ansible_become_method: enable
ansible_become_pass: password
ansible_facts_modules: myos_facts
Loading