forked from ansible/ansible-creator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scaffold ansible best practices directory structure (ansible#110)
* Initial changes for ansible project scaffolding * Test fixes * Add integration test, fixtures, ansible-code-bot.yml file * Add a check for test_run_init_no_input * Changes in inventory and other scaffolded files * Changes in ansible-code-bot.yml file and fixture additions * Add tests for cli_parser and ruff fixes * Add README.md * Modify .prettierignore file * Add unit test * Include devcontainer as part of ansible project scaffolding * Changes in ansible.cfg file * Add parameters scm-org and scm-project for ansible-project scaffolding * Replace placeholders in destination path with real values * Update the content in ansible-navigator.yml and README.md * Fix site.yml * Update ansible-core version and requirements.yml * Make scm_org and scm_project as primary namespace and collection_name for playbook adjacent collection scaffolding * Add check for scm-org or scm-project absence * Fix unit tests and add description for scm-org and scm-project params * Add tests and update fixtures * Address review changes * Pre-commit fixes * Update validation comments in dataclass * Use global output fixture defined in conftest.py * Add test for config changes * Add test for config changes: part2 * review changes
- Loading branch information
1 parent
9492c9c
commit 1e9d045
Showing
60 changed files
with
1,223 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# Stuff we don't want prettier to ever to look into | ||
tests/fixtures/collection/testorg/testcol/roles/ | ||
tests/fixtures/project/ansible_project/collections/ansible_collections/project_org/project_repo/roles/run/README.md | ||
tests/fixtures/project/ansible_project/.github/workflows/tests.yml | ||
tests/fixtures/project/ansible_project/collections/ansible_collections/weather/demo/roles/run/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/ansible_creator/resources/ansible_project/.devcontainer/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "ansible-dev-container-codespaces", | ||
"image": "ghcr.io/ansible/community-ansible-dev-tools-container:latest", | ||
"containerUser": "podman", | ||
"runArgs": [ | ||
"--security-opt", | ||
"seccomp=unconfined", | ||
"--security-opt", | ||
"label=disable", | ||
"--cap-add=SYS_ADMIN", | ||
"--cap-add=SYS_RESOURCE", | ||
"--device", | ||
"/dev/fuse", | ||
"--security-opt", | ||
"apparmor=unconfined", | ||
"--hostname=ansible-dev-container" | ||
], | ||
"updateRemoteUserUID": true, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["redhat.ansible"] | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/ansible_creator/resources/ansible_project/.devcontainer/docker/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "ansible-dev-container-docker", | ||
"image": "ghcr.io/ansible/community-ansible-dev-tools-container:latest", | ||
"containerUser": "podman", | ||
"runArgs": [ | ||
"--security-opt", | ||
"seccomp=unconfined", | ||
"--security-opt", | ||
"label=disable", | ||
"--cap-add=SYS_ADMIN", | ||
"--cap-add=SYS_RESOURCE", | ||
"--device", | ||
"/dev/fuse", | ||
"--security-opt", | ||
"apparmor=unconfined", | ||
"--hostname=ansible-dev-container" | ||
], | ||
"updateRemoteUserUID": true, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["redhat.ansible"] | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/ansible_creator/resources/ansible_project/.devcontainer/podman/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "ansible-dev-container-podman", | ||
"image": "ghcr.io/ansible/community-ansible-dev-tools-container:latest", | ||
"containerUser": "podman", | ||
"runArgs": [ | ||
"--security-opt", | ||
"seccomp=unconfined", | ||
"--security-opt", | ||
"label=disable", | ||
"--cap-add=SYS_ADMIN", | ||
"--cap-add=SYS_RESOURCE", | ||
"--device", | ||
"/dev/fuse", | ||
"--security-opt", | ||
"apparmor=unconfined", | ||
"--userns=keep-id:uid=1000,gid=1000", | ||
"--hostname=ansible-dev-container" | ||
], | ||
"updateRemoteUserUID": true, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["redhat.ansible"] | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/ansible_creator/resources/ansible_project/.github/ansible-code-bot.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
schedule: | ||
interval: "daily" |
18 changes: 18 additions & 0 deletions
18
src/ansible_creator/resources/ansible_project/.github/workflows/tests.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
name: "CI" | ||
{% raw %} | ||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
on: # yamllint disable-line rule:truthy | ||
pull_request: | ||
branches: [main] | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
ansible-lint: | ||
uses: ansible/ansible-content-actions/.github/workflows/ansible_lint.yaml@main | ||
{%- endraw %} |
3 changes: 3 additions & 0 deletions
3
src/ansible_creator/resources/ansible_project/.vscode/extensions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["redhat.ansible"] | ||
} |
44 changes: 44 additions & 0 deletions
44
src/ansible_creator/resources/ansible_project/README.md.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# {{ scm_org|capitalize }} {{ scm_project|capitalize }} Ansible Project | ||
|
||
## Included content/ Directory Structure | ||
|
||
The directory structure follows best practices recommended by the Ansible community. Feel free to customize this template according to your specific project requirements. | ||
|
||
``` | ||
ansible-project/ | ||
|── .devcontainer/ | ||
| └── docker/ | ||
| └── devcontainer.json | ||
| └── podman/ | ||
| └── devcontainer.json | ||
| └── devcontainer.json | ||
|── .github/ | ||
| └── workflows/ | ||
| └── tests.yml | ||
| └── ansible-code-bot.yml | ||
|── .vscode/ | ||
| └── extensions.json | ||
|── collections/ | ||
| └── requirements.yml | ||
| └── ansible_collections/ | ||
| └── project_org/ | ||
| └── project_repo/ | ||
| └── README.md | ||
| └── roles/sample_role/ | ||
| └── README.md | ||
| └── tasks/main.yml | ||
|── inventory/ | ||
| └── groups_vars/ | ||
| └── host_vars/ | ||
| └── hosts.yml | ||
|── ansible-navigator.yml | ||
|── ansible.cfg | ||
|── linux_playbook.yml | ||
|── network_playbook.yml | ||
|── README.md | ||
|── site.yml | ||
``` | ||
|
||
## Compatible with Ansible-lint | ||
|
||
Tested with ansible-lint >=24.2.0 releases and the current development version of ansible-core. |
17 changes: 17 additions & 0 deletions
17
src/ansible_creator/resources/ansible_project/ansible-navigator.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% raw %}--- | ||
ansible-navigator: | ||
logging: | ||
level: debug | ||
append: False | ||
file: $PWD/.logs/ansible-navigator.log | ||
|
||
execution-environment: | ||
enabled: true | ||
image: ghcr.io/ansible/community-ansible-dev-tools-container:latest | ||
pull: | ||
policy: always | ||
|
||
playbook-artifact: | ||
enable: True | ||
save-as: "$PWD/.logs/{playbook_name}-artifact-{time_stamp}.json" | ||
{%- endraw %} |
26 changes: 26 additions & 0 deletions
26
src/ansible_creator/resources/ansible_project/ansible.cfg.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[defaults] | ||
# Specify the inventory file | ||
inventory = inventory/hosts.yml | ||
|
||
# Define the directory for host and group variables | ||
host_vars_inventory = inventory/host_vars | ||
group_vars_inventory = inventory/group_vars | ||
|
||
# Specify the collections directory | ||
collections_paths = collections/ansible_collections | ||
|
||
# Set the logging verbosity level | ||
verbosity = 2 | ||
|
||
# Set the default user for SSH connections | ||
remote_user = myuser | ||
|
||
# Define the default become method | ||
become_method = sudo | ||
|
||
[persistent_connection] | ||
# Controls how long the persistent connection will remain idle before it is destroyed | ||
connect_timeout=30 | ||
|
||
# Controls the amount of time to wait for response from remote device before timing out persistent connection | ||
command_timeout=30 |
Oops, something went wrong.