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

Setup Ansible #1

Merged
merged 16 commits into from
Apr 20, 2024
Merged
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
14 changes: 14 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
version: 2
updates:
- package-ecosystem: devcontainers
directory: /
schedule:
interval: monthly
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
ci-dependencies:
patterns: ['*']
25 changes: 25 additions & 0 deletions .github/workflows/lint-ansible.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Lint Ansible playbooks
on:
push:
branches: [main]
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.x
allow-prereleases: true
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: python -m pip install .[ansible,lint_ansible]
- name: Run ansible lint
run: |-
cd ansible
ansible-lint --offline
9 changes: 9 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Lint
on:
push:
branches: [main]
pull_request:
jobs:
pre-commit:
uses: darbiadev/.github/.github/workflows/generic-precommit.yaml@29197a38ef3741064f47b623ede0c1ad22402c57 # v13.0.3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Python generated files
*.egg-info
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-yaml
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: mixed-line-ending
args: [--fix=lf]
- id: end-of-file-fixer
exclude: .devcontainer/devcontainer-lock.json
- repo: https://github.com/lyz-code/yamlfix/
rev: 1.16.0
hooks:
- id: yamlfix
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# infrastructure

Infrastructure for Tailstory
2 changes: 2 additions & 0 deletions ansible/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
skip_list: [package-latest]
6 changes: 6 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[defaults]
inventory = inventory/hosts.yaml

[privilege_escalation]
become = yes
become_ask_pass = yes
5 changes: 5 additions & 0 deletions ansible/inventory/hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
all:
hosts:
maddison:
ansible_host: maddison.box.tailstory.dev
4 changes: 4 additions & 0 deletions ansible/playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Deploy common services
hosts: all
roles: [common, docker]
6 changes: 6 additions & 0 deletions ansible/roles/common/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Update all packages to their latest version
ansible.builtin.apt:
name: '*'
state: latest
update_cache: true
21 changes: 21 additions & 0 deletions ansible/roles/docker/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Install aptitude
ansible.builtin.apt:
name: aptitude
state: latest
- name: Install required system packages
ansible.builtin.apt:
pkg: [ca-certificates, curl]
state: latest
- name: Add Docker GPG apt Key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/ubuntu jammy stable
state: present
- name: Update apt and install docker-ce
ansible.builtin.apt:
name: docker-ce
state: latest
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[project]
name = "infrastructure"
version = "0.0.0" # explicity non-versioned
description = "Infrastructure for Tailstory"
authors = [
{ name = "Bradley Reynolds", email = "[email protected]" },
]
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
]

[project.urls]
repository = "https://github.com/tailstory/infrastructure"

[project.optional-dependencies]
ansible = [
"ansible>=9.4.0",
]
lint_ansible = [
"ansible-lint>=24.2.2; platform_system != 'Windows'",
]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = [] # no python packages

# I want this, but it adds random indents which cause syntax errors
# [tool.yamlfix]
# explicit_start = false