Skip to content

Commit

Permalink
feat(ansible): add fedora boilerplates
Browse files Browse the repository at this point in the history
  • Loading branch information
ttybitnik committed Jan 11, 2025
1 parent e1a9ccf commit 0a75bcb
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 0 deletions.
25 changes: 25 additions & 0 deletions boilerplates/ansible/fedora/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# MKDEVENV 0.1.0 (x-release-please-version)
FROM docker.io/fedora:latest

ARG USERNAME=mkdevenv

LABEL mkdevenv.name="ansible-fedora" \
mkdevenv.summary="Image with general tools for developing Ansible-related projects" \
mkdevenv.usage="For more information, see <https://github.com/ttybitnik/mkdevenv>"

COPY .mkdevenv/*.txt /tmp/

RUN dnf update -y && xargs -n 1 dnf install -y < /tmp/dnf.txt && dnf clean all \
&& adduser $USERNAME \
&& chown $USERNAME:$USERNAME /tmp/*.txt

WORKDIR /home/$USERNAME/workspace

USER $USERNAME

ENV NPM_CONFIG_PREFIX="/home/$USERNAME/.local"

RUN pip3 install --no-cache-dir -r /tmp/pip.txt
RUN xargs -n 1 npm install -g < /tmp/npm.txt && npm cache clean --force

CMD ["/bin/bash", "-l"]
80 changes: 80 additions & 0 deletions boilerplates/ansible/fedora/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# MKDEVENV 0.1.0 (x-release-please-version)
# See <https://github.com/ttybitnik/mkdevenv> for more information.

PROJECT_NAME = changeme
CONTAINER_ENGINE = changeme

__USER = $(or $(USER),$(shell whoami))

# Host targets/commands
.PHONY: devenv start stop clean serestore

devenv:
$(info Building development container image...)

$(CONTAINER_ENGINE) build \
--build-arg USERNAME=$(__USER) \
-f .mkdevenv/Containerfile \
-t localhost/mkdevenv/$(PROJECT_NAME) \
.

start:
$(info Starting development container...)

$(CONTAINER_ENGINE) run -it -d --replace \
$(if $(filter podman,$(CONTAINER_ENGINE)),--userns=keep-id) \
--name mkdevenv-$(PROJECT_NAME) \
--volume .:/home/$(__USER)/workspace:Z \
localhost/mkdevenv/$(PROJECT_NAME):latest

@# $(CONTAINER_ENGINE) compose .mkdevenv/compose.yaml up -d

stop:
$(info Stopping development container...)

$(CONTAINER_ENGINE) stop mkdevenv-$(PROJECT_NAME)

@# $(CONTAINER_ENGINE) compose .mkdevenv/compose.yaml down

clean: distclean
$(info Removing development container and image...)

-$(CONTAINER_ENGINE) rm mkdevenv-$(PROJECT_NAME)
-$(CONTAINER_ENGINE) image rm localhost/mkdevenv/$(PROJECT_NAME)

@# $(CONTAINER_ENGINE) image prune

serestore:
$(info Restoring project SELinux context and permissions...)

chcon -Rv unconfined_u:object_r:user_home_t:s0 .
# find . -type d -exec chmod 700 {} \;
# find . -type f -exec chmod 600 {} \;

# Container targets/commands
.PHONY: lint test build run deploy debug distclean

lint:
$(info Running linters...)

yamllint .
ansible-lint
ansible-playbook --syntax-check *yaml

test: lint
$(info Running tests...)

build: test
$(info Building...)

run: build
$(info Running...)

deploy: build
$(info Deploying...)

debug: test
$(info Debugging tasks...)

distclean:
$(info Cleaning artifacts...)
17 changes: 17 additions & 0 deletions boilerplates/ansible/fedora/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ansible-fedora

| dnf | npm | pip |
|:-------------|:---------------------------------|:-------------|
| git | yaml-language-server | yamllint |
| make | @ansible/ansible-language-server | ansible-lint |
| ripgrep | | molecule |
| npm | | |
| python3 | | |
| python3-pip | | |
| ansible-core | | |

1. Create a `.mkdevenv` directory at the root of the project.
2. Copy all the boilerplate files into the `.mkdevenv` directory.
3. Move the `Makefile` to the root of the project.

*For more information, see <https://github.com/ttybitnik/mkdevenv>.*
7 changes: 7 additions & 0 deletions boilerplates/ansible/fedora/dnf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
git
make
ripgrep
npm
python3
python3-pip
ansible-core
2 changes: 2 additions & 0 deletions boilerplates/ansible/fedora/npm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yaml-language-server
@ansible/ansible-language-server
3 changes: 3 additions & 0 deletions boilerplates/ansible/fedora/pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yamllint
ansible-lint
molecule

0 comments on commit 0a75bcb

Please sign in to comment.