Skip to content

Commit

Permalink
feat: Ansible project support
Browse files Browse the repository at this point in the history
Adds support for generating a project which will use Ansible. Creates a base inventory, playbook, and installs the necessary tooling for working within the Ansible ecosystem.
  • Loading branch information
jwbennet committed Feb 27, 2024
1 parent 6fef270 commit c0c54c5
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions ansible/.devcontainer/devcontainer.json.jinja
1 change: 1 addition & 0 deletions ansible/.editorconfig
1 change: 1 addition & 0 deletions ansible/CHANGELOG.md.jinja
34 changes: 34 additions & 0 deletions ansible/Taskfile.yaml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3"

tasks:
docs:
desc: Start a server which serves the project documentation
cmds:
- mkdocs serve {% if git_provider == 'github' %}--config-file=.github/.mkdocsrc{% endif %}
inventory:
desc: Display the inventory as seen from Ansible in graph form
cmds:
- ansible-inventory --graph
inventory-list:
desc: Display the inventory as seen from Ansible in list form
cmds:
- ansible-inventory --list
lint:
desc: Check the syntax of Ansible playbooks
cmds:
- ansible-lint
run:
desc: Run playbook
cmds:
- ansible-playbook main.yaml
setup:
desc: Install dependencies and setup the project
cmds:
- pre-commit install {%- if git_provider == 'github' %} --config .github/.precommitrc{% endif %} --hook-type pre-commit --hook-type commit-msg
- pip install --user ansible-lint
- ansible-galaxy install -r requirements.yaml
default:
cmds:
- task --list

silent: true
2 changes: 2 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
inventory = ./inventory.yaml
5 changes: 5 additions & 0 deletions ansible/inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
ungrouped:
hosts:
localhost:
ansible_connection: local
7 changes: 7 additions & 0 deletions ansible/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Demo Playbook
hosts: all
tasks:
- name: Debug information
ansible.builtin.debug:
msg: "The hostname is {{ ansible_hostname }}"
7 changes: 7 additions & 0 deletions ansible/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
collections:
- name: ansible.utils
version: 3.0.0
# roles:
# - name: TBD
# version: TBD
1 change: 1 addition & 0 deletions ansible/version.txt.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
{
"name": "{{project_name}}",
"image": "ghcr.io/jwbennet/project-base-dev-container:2.2.0",
"features": {
// renovate: depType=devcontainerFeature datasource=docker
"ghcr.io/devcontainers-contrib/features/ansible:2.0.17": {
// renovate: depType=devDependencies datasource=github-tags depName=ansible/ansible extractVersion=true
"version": "2.16.3"
}
}
}
1 change: 1 addition & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project_type:
type: str
help: Which type of project to copy?
choices:
Ansible: ansible
Generic: generic
default: generic
custom_devcontainer_features:
Expand Down

0 comments on commit c0c54c5

Please sign in to comment.