Browse Source

feat: add ansible

pull/3/head
Karan Sharma 1 year ago
parent
commit
1d643598ff
  1. 0
      hetzner/ansible/Makefile
  2. 9
      hetzner/ansible/README.md
  3. 5
      hetzner/ansible/ansible.cfg
  4. 9
      hetzner/ansible/inventory.sample
  5. 23
      hetzner/ansible/playbook.yml
  6. 18
      hetzner/ansible/roles/bootstrap-node/handlers/main.yml
  7. 28
      hetzner/ansible/roles/bootstrap-node/tasks/apt.yml
  8. 89
      hetzner/ansible/roles/bootstrap-node/tasks/docker.yml
  9. 7
      hetzner/ansible/roles/bootstrap-node/tasks/hostname.yml
  10. 4
      hetzner/ansible/roles/bootstrap-node/tasks/locale.yml
  11. 29
      hetzner/ansible/roles/bootstrap-node/tasks/main.yml
  12. 69
      hetzner/ansible/roles/bootstrap-node/tasks/ssh.yml
  13. 3
      hetzner/ansible/roles/bootstrap-node/tasks/timezone.yml
  14. 31
      hetzner/ansible/roles/bootstrap-node/tasks/user.yml
  15. 7
      hetzner/ansible/roles/bootstrap-node/templates/daemon.json
  16. 8
      hetzner/ansible/roles/bootstrap-node/templates/ssh-banner.j2
  17. 1
      hetzner/ansible/roles/bootstrap-node/vars/main.yml
  18. 23
      hetzner/ansible/roles/gantsign.antigen/.editorconfig
  19. 25
      hetzner/ansible/roles/gantsign.antigen/.gitattributes
  20. 297
      hetzner/ansible/roles/gantsign.antigen/.gitignore
  21. 1
      hetzner/ansible/roles/gantsign.antigen/.moleculew/ansible_version
  22. 1
      hetzner/ansible/roles/gantsign.antigen/.moleculew/docker_lib_version
  23. 1
      hetzner/ansible/roles/gantsign.antigen/.moleculew/molecule_version
  24. 1
      hetzner/ansible/roles/gantsign.antigen/.moleculew/python_version
  25. 76
      hetzner/ansible/roles/gantsign.antigen/.travis.yml
  26. 13
      hetzner/ansible/roles/gantsign.antigen/.yamllint
  27. 21
      hetzner/ansible/roles/gantsign.antigen/LICENSE
  28. 198
      hetzner/ansible/roles/gantsign.antigen/README.md
  29. 15
      hetzner/ansible/roles/gantsign.antigen/defaults/main.yml
  30. 4
      hetzner/ansible/roles/gantsign.antigen/handlers/main.yml
  31. 2
      hetzner/ansible/roles/gantsign.antigen/meta/.galaxy_install_info
  32. 33
      hetzner/ansible/roles/gantsign.antigen/meta/main.yml
  33. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/centos/Dockerfile.j2
  34. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/centos/INSTALL.rst
  35. 29
      hetzner/ansible/roles/gantsign.antigen/molecule/centos/molecule.yml
  36. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/debian_max/Dockerfile.j2
  37. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/debian_max/INSTALL.rst
  38. 29
      hetzner/ansible/roles/gantsign.antigen/molecule/debian_max/molecule.yml
  39. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/debian_min/Dockerfile.j2
  40. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/debian_min/INSTALL.rst
  41. 29
      hetzner/ansible/roles/gantsign.antigen/molecule/debian_min/molecule.yml
  42. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/default/Dockerfile.j2
  43. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/default/INSTALL.rst
  44. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/default/molecule.yml
  45. 68
      hetzner/ansible/roles/gantsign.antigen/molecule/default/playbook.yml
  46. 16
      hetzner/ansible/roles/gantsign.antigen/molecule/default/tests/console-setup.sh
  47. 272
      hetzner/ansible/roles/gantsign.antigen/molecule/default/tests/test_role.py
  48. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/fedora/Dockerfile.j2
  49. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/fedora/INSTALL.rst
  50. 29
      hetzner/ansible/roles/gantsign.antigen/molecule/fedora/molecule.yml
  51. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/opensuse/Dockerfile.j2
  52. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/opensuse/INSTALL.rst
  53. 29
      hetzner/ansible/roles/gantsign.antigen/molecule/opensuse/molecule.yml
  54. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_max/Dockerfile.j2
  55. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_max/INSTALL.rst
  56. 29
      hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_max/molecule.yml
  57. 14
      hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_min/Dockerfile.j2
  58. 26
      hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_min/INSTALL.rst
  59. 29
      hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_min/molecule.yml
  60. 792
      hetzner/ansible/roles/gantsign.antigen/moleculew
  61. 27
      hetzner/ansible/roles/gantsign.antigen/tasks/configure-debian-console.yml
  62. 98
      hetzner/ansible/roles/gantsign.antigen/tasks/configure.yml
  63. 26
      hetzner/ansible/roles/gantsign.antigen/tasks/install-oh-my-zsh.yml
  64. 50
      hetzner/ansible/roles/gantsign.antigen/tasks/install.yml
  65. 4
      hetzner/ansible/roles/gantsign.antigen/tasks/main.yml
  66. 21
      hetzner/ansible/roles/gantsign.antigen/templates/antigenrc.j2
  67. 33
      hetzner/ansible/roles/gantsign.antigen/templates/bundle.zsh.j2
  68. 11
      hetzner/ansible/roles/gantsign.antigen/templates/theme.zsh.j2
  69. 14
      hetzner/ansible/roles/gantsign.antigen/templates/use.zsh.j2
  70. 10
      hetzner/ansible/roles/gantsign.antigen/vars/main.yml
  71. 9
      hetzner/floating_ip.tf
  72. 0
      hetzner/terraform/.env.sample
  73. 0
      hetzner/terraform/README.md
  74. 9
      hetzner/terraform/floating_ip.tf
  75. 7
      hetzner/terraform/main.tf
  76. 4
      hetzner/terraform/network.tf
  77. 0
      hetzner/terraform/variables.tf

0
hetzner/firewalls.tf → hetzner/ansible/Makefile

9
hetzner/ansible/README.md

@ -0,0 +1,9 @@
# Ansible Playbook for setting up Hydra Home Server
## Running
## Imp things to keep in mind
1) `ansible_ssh_user` for the first run is `root` since there is no user in the instance.
You must ensure that `bootstrap-nodes` role is first run before continuing. It disables the `root` SSH login to the instance and only
the `username` supplied in `inventory` has access to SSH. If you fail at this step, you need to debug before proceeding.

5
hetzner/ansible/ansible.cfg

@ -0,0 +1,5 @@
[defaults]
roles_path = ./roles
inventory = ./inventory
[ssh_connection]
scp_if_ssh = True

9
hetzner/ansible/inventory.sample

@ -0,0 +1,9 @@
[hydra:children]
srv1
[srv1]
srv1 ansible_ssh_host=srv1 ansible_ssh_user=username ansible_ssh_port=22 remote_ssh_user=user
[srv1:vars]
username=username
github_ssh_key_url=https://github.com/username.keys

23
hetzner/ansible/playbook.yml

@ -0,0 +1,23 @@
---
- hosts: all
become: yes
become_method: sudo
roles:
- bootstrap-node
- role: gantsign.antigen
users:
- username: "{{username}}"
antigen_libraries:
- name: oh-my-zsh
antigen_theme:
name: cloud
antigen_bundles:
# Bundles from the default repo (robbyrussell's oh-my-zsh).
- name: git
- name: pip
- name: fzf
- name: command-not-found
# Syntax highlighting bundle.
- name: zsh-syntax-highlighting # `name` is required (any valid file name will do so long as it's unique for the bundles)
url: zsh-users/zsh-syntax-highlighting

18
hetzner/ansible/roles/bootstrap-node/handlers/main.yml

@ -0,0 +1,18 @@
- name: restart sshd
service:
name: ssh
state: restarted
- name: reboot
reboot:
- name: Start docker on boot
systemd:
name: docker
state: started
enabled: yes
- name: Restart Docker
systemd:
name: docker
state: restarted

28
hetzner/ansible/roles/bootstrap-node/tasks/apt.yml

@ -0,0 +1,28 @@
- name: Update apt cache and upgrade
apt:
update_cache: yes
upgrade: "yes"
- name: Install dependencies
apt:
name: "{{ packages }}"
vars:
packages:
- apt-transport-https
- vim
- curl
- jq
- fzf
- name: install unattended-upgrades
apt:
name: "unattended-upgrades"
state: present
- name: Remove useless packages from the cache
apt:
autoclean: yes
- name: Remove dependencies that are no longer required
apt:
autoremove: yes

89
hetzner/ansible/roles/bootstrap-node/tasks/docker.yml

@ -0,0 +1,89 @@
# sudo apt-get install *
- name: Install docker packages
apt:
name:
[
"apt-transport-https",
"ca-certificates",
"curl",
"gnupg-agent",
"software-properties-common",
]
state: present
update_cache: yes
tags:
- docker
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- name: Add Docker s official GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
tags:
- docker
# sudo apt-key fingerprint 0EBFCD88
- name: Verify that we have the key with the fingerprint
apt_key:
id: 0EBFCD88
state: present
tags:
- docker
# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- name: Set up the stable repository
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
state: present
update_cache: yes
tags:
- docker
# sudo apt-get update
- name: Update apt packages
apt:
update_cache: yes
tags:
- docker
# sudo apt-get install docker-ce
- name: Install docker
apt:
state: present
update_cache: yes
name: ["docker-ce", "docker-ce-cli", "containerd.io"]
notify: Start docker on boot
tags:
- docker
# sudo groupadd docker
- name: Create "docker" group
group:
name: "docker"
state: present
tags:
- docker
# sudo usermod -aG docker <user>
- name: Add remote user to "docker" group
user:
name: "{{username}}"
group: "docker"
append: yes
tags:
- docker
- name: Configure sane defaults for logging (docker daemon)
template:
src: "daemon.json"
dest: "/etc/docker/daemon.json"
owner: "root"
group: "root"
mode: "0644"
notify: Restart Docker
- name: Install Docker-compose
shell: sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- name: Changing perm of /usr/local/bin/docker-compose
file: dest=/usr/local/bin/docker-compose mode=a+x

7
hetzner/ansible/roles/bootstrap-node/tasks/hostname.yml

@ -0,0 +1,7 @@
---
- name: updating hostname to {{inventory_hostname}} from {{ansible_hostname}}
hostname:
name: "{{inventory_hostname}}"
notify:
- reboot

4
hetzner/ansible/roles/bootstrap-node/tasks/locale.yml

@ -0,0 +1,4 @@
- name: Ensure US locale exists
locale_gen:
name: en_US.UTF-8
state: present

29
hetzner/ansible/roles/bootstrap-node/tasks/main.yml

@ -0,0 +1,29 @@
---
- import_tasks: apt.yml
tags:
- apt
- import_tasks: locale.yml
tags:
- locale
- import_tasks: user.yml
tags:
- user
- import_tasks: ssh.yml
tags:
- ssh
- import_tasks: timezone.yml
tags:
- timezone
- import_tasks: docker.yml
tags:
- docker
- import_tasks: hostname.yml
tags:
- hostname

69
hetzner/ansible/roles/bootstrap-node/tasks/ssh.yml

@ -0,0 +1,69 @@
---
- name: disable ssh remote root login
lineinfile:
dest: "{{ ssh_sshd_config }}"
regexp: "^#?PermitRootLogin"
line: "PermitRootLogin no"
state: present
notify:
- restart sshd
- name: enable ssh strict mode
lineinfile:
dest: "{{ ssh_sshd_config }}"
regexp: "^#?StrictModes"
line: "StrictModes yes"
state: present
notify:
- restart sshd
- name: disable X11 forwarding
lineinfile:
dest: "{{ ssh_sshd_config }}"
regexp: "^#?X11Forwarding"
line: "X11Forwarding no"
state: present
notify:
- restart sshd
- name: disable ssh password login
lineinfile:
dest: "{{ ssh_sshd_config }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
with_items:
- regexp: "^#?PasswordAuthentication"
line: "PasswordAuthentication no"
- regexp: "^#?ChallengeResponseAuthentication"
line: "ChallengeResponseAuthentication no"
- regexp: "^#?PermitEmptyPasswords"
line: "PermitEmptyPasswords no"
notify:
- restart sshd
- name: set ssh allowed users to {{ username }}
lineinfile:
dest: "{{ ssh_sshd_config }}"
regexp: "^#?AllowUsers"
line: "AllowUsers {{ username }}"
notify:
- restart sshd
when: username != None
- name: add ssh banner info
lineinfile:
dest: "{{ ssh_sshd_config }}"
regexp: "^#?Banner"
line: "Banner /etc/issue.net"
state: present
notify:
- restart sshd
- name: update ssh banner
template:
src: ssh-banner.j2
dest: /etc/issue.net
notify:
- restart sshd

3
hetzner/ansible/roles/bootstrap-node/tasks/timezone.yml

@ -0,0 +1,3 @@
- name: Set timezone to Asia/Kolkata
timezone:
name: Asia/Kolkata

31
hetzner/ansible/roles/bootstrap-node/tasks/user.yml

@ -0,0 +1,31 @@
---
- name: Make sure we have a 'wheel' group
group:
name: wheel
state: present
- name: Allow 'wheel' group to have passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
- name: Create user and grant sudo access
user:
name: "{{username}}"
groups:
- wheel
append: yes
state: present
createhome: yes
shell: /bin/bash
- name: Set authorized key for user
authorized_key:
user: "{{username}}"
state: present
key: "{{github_ssh_key_url}}"
when: github_ssh_key_url != None

7
hetzner/ansible/roles/bootstrap-node/templates/daemon.json

@ -0,0 +1,7 @@
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "10"
}
}

8
hetzner/ansible/roles/bootstrap-node/templates/ssh-banner.j2

@ -0,0 +1,8 @@
********************************************************************
* Welcome to Hydra! The HomeLab Server. *
* *
* This system is for the use of authorized users only. Usage of *
* this system may be monitored and recorded by system personnel. *
* *
********************************************************************

1
hetzner/ansible/roles/bootstrap-node/vars/main.yml

@ -0,0 +1 @@
ssh_sshd_config: "/etc/ssh/sshd_config"

23
hetzner/ansible/roles/gantsign.antigen/.editorconfig

@ -0,0 +1,23 @@
# EditorConfig: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Defaults for all editor files
[*]
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
# YAML is fussy about indenting and charset
[*.yml]
indent_style = space
indent_size = 2
continuation_indent_size = unset
charset = utf-8
# Markdown is fussy about indenting
[*.md]
indent_style = space
indent_size = 4

25
hetzner/ansible/roles/gantsign.antigen/.gitattributes

@ -0,0 +1,25 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
LICENSE text
.editorconfig text
.gitattributes text
.gitignore text
.yamllint text
*.cfg text
*.j2 text
*.md text
*.py text
*.yml text
# Declare files that will always have LF line endings on checkout.
*.sh text eol=lf
# Denote all files that are truly binary and should not be modified.
*.gif binary
*.jpeg binary
*.jpg binary
*.png binary

297
hetzner/ansible/roles/gantsign.antigen/.gitignore

@ -0,0 +1,297 @@
# Created by https://www.gitignore.io/api/windows,linux,osx,vim,emacs,intellij,eclipse,visualstudiocode,ansible
### Ansible ###
*.retry
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Annotation Processing
.apt_generated
### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Linux ###
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/windows,linux,osx,vim,emacs,intellij,eclipse,visualstudiocode,ansible
####################
### Custom rules ###
####################
### Molecule ###
__pycache__
.cache
.molecule

1
hetzner/ansible/roles/gantsign.antigen/.moleculew/ansible_version

@ -0,0 +1 @@
2.7.0

1
hetzner/ansible/roles/gantsign.antigen/.moleculew/docker_lib_version

@ -0,0 +1 @@
3.5.0

1
hetzner/ansible/roles/gantsign.antigen/.moleculew/molecule_version

@ -0,0 +1 @@
2.17.0

1
hetzner/ansible/roles/gantsign.antigen/.moleculew/python_version

@ -0,0 +1 @@
2.7.15

76
hetzner/ansible/roles/gantsign.antigen/.travis.yml

@ -0,0 +1,76 @@
---
language: python
python: '2.7'
env:
global:
- MOLECULEW_USE_SYSTEM=true
# Spin off separate builds for each of the following versions
# of Ansible and Linux.
matrix:
include:
- env:
- MOLECULEW_ANSIBLE=2.5.10
- MOLECULE_SCENARIO=centos
- env:
- MOLECULEW_ANSIBLE=2.5.10
- MOLECULE_SCENARIO=debian_max
- env:
- MOLECULEW_ANSIBLE=2.5.10
- MOLECULE_SCENARIO=debian_min
- env:
- MOLECULEW_ANSIBLE=2.5.10
- MOLECULE_SCENARIO=ubuntu_max
- env:
- MOLECULEW_ANSIBLE=2.5.10
- MOLECULE_SCENARIO=ubuntu_min
- env:
- MOLECULEW_ANSIBLE=2.5.10
- MOLECULE_SCENARIO=opensuse
- env:
- MOLECULEW_ANSIBLE=2.7.0
- MOLECULE_SCENARIO=centos
- env:
- MOLECULEW_ANSIBLE=2.7.0
- MOLECULE_SCENARIO=debian_max
- env:
- MOLECULEW_ANSIBLE=2.7.0
- MOLECULE_SCENARIO=debian_min
- env:
- MOLECULEW_ANSIBLE=2.7.0
- MOLECULE_SCENARIO=ubuntu_max
- env:
- MOLECULEW_ANSIBLE=2.7.0
- MOLECULE_SCENARIO=ubuntu_min
- env:
- MOLECULEW_ANSIBLE=2.7.0
- MOLECULE_SCENARIO=opensuse
# Require the standard build environment
sudo: required
# Require Ubuntu 14.04
dist: trusty
# Require Docker
services:
- docker
install:
# Install dependencies
- ./moleculew wrapper-install
# Display versions
- ./moleculew wrapper-versions
script:
- ./moleculew test --scenario-name=$MOLECULE_SCENARIO
branches:
only:
- master
- /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([\.\-].*)?$/
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

13
hetzner/ansible/roles/gantsign.antigen/.yamllint

@ -0,0 +1,13 @@
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
truthy: disable

21
hetzner/ansible/roles/gantsign.antigen/LICENSE

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 GantSign Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

198
hetzner/ansible/roles/gantsign.antigen/README.md

@ -0,0 +1,198 @@
Ansible Role: Antigen
=====================
[![Build Status](https://travis-ci.com/gantsign/ansible_role_antigen.svg?branch=master)](https://travis-ci.com/gantsign/ansible_role_antigen)
[![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-gantsign.antigen-blue.svg)](https://galaxy.ansible.com/gantsign/antigen)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/gantsign/ansible_role_antigen/master/LICENSE)
Role to install the [Antigen](http://antigen.sharats.me/) plugin manger for Zsh
and use it to configure Zsh.
This role has a companion role that enables you to conditionally install
particular Antigen bundles. You can find details of that role at
[gantsign.antigen_budles](https://galaxy.ansible.com/gantsign/antigen_bundles).
Requirements
------------
* Ansible >= 2.5
* Linux Distribution
* Debian Family
* Debian
* Jessie (8)
* Stretch (9)
* Ubuntu
* Trusty (14.04)
* Xenial (16.04)
* Bionic (18.04)
* RedHat Family
* CentOS
* 7
* Fedora
* 28
* SUSE Family
* openSUSE
* 15.0
* Note: other versions are likely to work but have not been tested.
Role Variables
--------------
The following variables will change the behavior of this role:
```yaml
# Antigen version number
antigen_version: '2.0.2'
# SHA256 sum for the redistributable package
antigen_redis_sha256sum: 'f47ec933b32c578abe8cb39b24e0ddd114ef5cc01b3c05bcb634859ead31493f'
# Should Oh-My-Zsh be installed with Antigen (doesn't call `antigen use`)
antigen_install_oh_my_zsh: yes
# Mirror location for Antigen download
antigen_redis_mirror: 'https://github.com/zsh-users/antigen/releases/download/v{{ antigen_version }}'
# Directory to store files downloaded for Antigen installation on the remote box
antigen_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# Antigen is installed per user so you need to specify the users to install it for
users:
- username: # The username of the user to install Antigen for
antigen_libraries:
- name: # The name of the library (e.g. oh-my-zsh or prezto) must be unique
url: # Optional. If you're using a custom library you must specify the Git URL
args: # Optional. Command line arguments to pass to Antigen
- '--exampleParam1'
- 'paramValue1' # example with value passed as a separate arg
- '--exampleParam2=paramValue2' # example with value passed in the same arg
env: # Optional. Environnement variables to set
EXAMPLE_ENV1: 'envValue1'
EXAMPLE_ENV2: '"${HOME}/.example"' # the single quotes are for YAML the double quotes are for the shell
# more libraries here
antigen_theme:
name: # The name of the library (e.g. one of the themes that come with Oh-My-Zsh)
url: # Optional. If the theme doesn't come with Oh-My-Zsh you must specify the Git URL
env: {} # Optional. Environnement variables to set
antigen_bundles:
- name: # The name of the Antigen bundle (e.g. one of the plugins that come with Oh-My-Zsh)
url: # Optional. If the it's not one of the Oh-My-Zsh plugins you must specify the URL (use owner/repo shorthand for GitHub)
location: # Optional. The directory in the repository containing the plugin
branch: # Optional. Git branch to checkout.
tag: # Optional. Git tag to checkout (takes preference over branch)
args: [] # Optional. Command line arguments to pass to Antigen
env: {} # Optional. Environnement variables to set
# more bundles here
# more users here
```
Example Playbooks
-----------------
The following achieves the same as the example in the Antigen
[README.mkd](https://github.com/zsh-users/antigen/blob/develop/README.mkd#usage).
```yaml
- hosts: servers
roles:
- role: gantsign.antigen
users:
- username: example
antigen_libraries:
- name: oh-my-zsh
antigen_theme:
name: robbyrussell
antigen_bundles:
# Bundles from the default repo (robbyrussell's oh-my-zsh).
- name: git
- name: heroku
- name: pip
- name: lein
- name: command-not-found
# Syntax highlighting bundle.
- name: zsh-syntax-highlighting # `name` is required (any valid file name will do so long as it's unique for the bundles)
url: zsh-users/zsh-syntax-highlighting
```
The following achieves the same as the example in the `gantsign.oh-my-zsh` role
[README.md](https://github.com/gantsign/ansible-role-oh-my-zsh/blob/master/README.md#example-playbook)
```yaml
- hosts: servers
roles:
- role: gantsign.antigen
users:
- username: example
antigen_libraries:
- name: oh-my-zsh
env:
DISABLE_AUTO_UPDATE: '"true"' # Optional (this was hard-coded in the .zshrc of the `gantsign.oh-my-zsh` role)
antigen_theme:
name: robbyrussell # This role has no default theme (unlike the `gantsign.oh-my-zsh` role)
antigen_bundles:
- name: git # This role has no default bundles/plugins (unlike the `gantsign.oh-my-zsh` role)
```
More Roles From GantSign
------------------------
You can find more roles from GantSign on
[Ansible Galaxy](https://galaxy.ansible.com/gantsign).
Development & Testing
---------------------
This project uses [Molecule](http://molecule.readthedocs.io/) to aid in the
development and testing; the role is unit tested using
[Testinfra](http://testinfra.readthedocs.io/) and
[pytest](http://docs.pytest.org/).
To develop or test you'll need to have installed the following:
* Linux (e.g. [Ubuntu](http://www.ubuntu.com/))
* [Docker](https://www.docker.com/)
* [Python](https://www.python.org/) (including python-pip)
* [Ansible](https://www.ansible.com/)
* [Molecule](http://molecule.readthedocs.io/)
Because the above can be tricky to install, this project includes
[Molecule Wrapper](https://github.com/gantsign/molecule-wrapper). Molecule
Wrapper is a shell script that installs Molecule and it's dependencies (apart
from Linux) and then executes Molecule with the command you pass it.
To test this role using Molecule Wrapper run the following command from the
project root:
```bash
./moleculew test
```
Note: some of the dependencies need `sudo` permission to install.
License
-------
MIT
Author Information
------------------
John Freeman
GantSign Ltd.
Company No. 06109112 (registered in England)

15
hetzner/ansible/roles/gantsign.antigen/defaults/main.yml

@ -0,0 +1,15 @@
---
# Antigen version number
antigen_version: '2.0.2'
# SHA256 sum for the redistributable package
antigen_redis_sha256sum: 'f47ec933b32c578abe8cb39b24e0ddd114ef5cc01b3c05bcb634859ead31493f'
# Should Oh-My-Zsh be installed with Antigen (doesn't call `antigen use`)
antigen_install_oh_my_zsh: yes
# Mirror location for Antigen download
antigen_redis_mirror: 'https://github.com/zsh-users/antigen/releases/download/v{{ antigen_version }}'
# Directory to store files downloaded for Antigen installation on the remote box
antigen_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"

4
hetzner/ansible/roles/gantsign.antigen/handlers/main.yml

@ -0,0 +1,4 @@
---
- name: dpkg-reconfigure console-setup
become: yes
command: /usr/sbin/dpkg-reconfigure -f noninteractive console-setup

2
hetzner/ansible/roles/gantsign.antigen/meta/.galaxy_install_info

@ -0,0 +1,2 @@
install_date: Fri Jul 31 19:26:13 2020
version: 1.3.2

33
hetzner/ansible/roles/gantsign.antigen/meta/main.yml

@ -0,0 +1,33 @@
---
galaxy_info:
author: John Freeman
role_name: antigen
description: Role for installing the Antigen plugin manger for Zsh and using it to configure Zsh.
company: GantSign Ltd.
license: MIT
min_ansible_version: 2.5
platforms:
- name: EL
versions:
- 7
- name: Fedora
versions:
- 28
- name: Ubuntu
versions:
- trusty
- xenial
- bionic
- name: Debian
versions:
- jessie
- stretch
- name: opensuse
versions:
- '15.0'
galaxy_tags:
- antigen
- ohmyzsh
- zsh
- shell
dependencies: []

14
hetzner/ansible/roles/gantsign.antigen/molecule/centos/Dockerfile.j2

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

26
hetzner/ansible/roles/gantsign.antigen/molecule/centos/INSTALL.rst

@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
Ansible < 2.6
.. code-block:: bash
$ sudo pip install docker-py
Ansible >= 2.6
.. code-block:: bash
$ sudo pip install docker

29
hetzner/ansible/roles/gantsign.antigen/molecule/centos/molecule.yml

@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ansible_role_antigen_centos
image: centos:7
provisioner:
name: ansible
playbooks:
converge: ../default/playbook.yml
lint:
name: ansible-lint
scenario:
name: centos
verifier:
name: testinfra
directory: ../default/tests/
lint:
name: flake8

14
hetzner/ansible/roles/gantsign.antigen/molecule/debian_max/Dockerfile.j2

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

26
hetzner/ansible/roles/gantsign.antigen/molecule/debian_max/INSTALL.rst

@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
Ansible < 2.6
.. code-block:: bash
$ sudo pip install docker-py
Ansible >= 2.6
.. code-block:: bash
$ sudo pip install docker

29
hetzner/ansible/roles/gantsign.antigen/molecule/debian_max/molecule.yml

@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ansible_role_antigen_debian_max
image: debian:9
provisioner:
name: ansible
playbooks:
converge: ../default/playbook.yml
lint:
name: ansible-lint
scenario:
name: debian_max
verifier:
name: testinfra
directory: ../default/tests/
lint:
name: flake8

14
hetzner/ansible/roles/gantsign.antigen/molecule/debian_min/Dockerfile.j2

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

26
hetzner/ansible/roles/gantsign.antigen/molecule/debian_min/INSTALL.rst

@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
Ansible < 2.6
.. code-block:: bash
$ sudo pip install docker-py
Ansible >= 2.6
.. code-block:: bash
$ sudo pip install docker

29
hetzner/ansible/roles/gantsign.antigen/molecule/debian_min/molecule.yml

@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ansible_role_antigen_debian_min
image: debian:8
provisioner:
name: ansible
playbooks:
converge: ../default/playbook.yml
lint:
name: ansible-lint
scenario:
name: debian_min
verifier:
name: testinfra
directory: ../default/tests/
lint:
name: flake8

14
hetzner/ansible/roles/gantsign.antigen/molecule/default/Dockerfile.j2

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

26
hetzner/ansible/roles/gantsign.antigen/molecule/default/INSTALL.rst

@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
Ansible < 2.6
.. code-block:: bash
$ sudo pip install docker-py
Ansible >= 2.6
.. code-block:: bash
$ sudo pip install docker

26
hetzner/ansible/roles/gantsign.antigen/molecule/default/molecule.yml

@ -0,0 +1,26 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ansible_role_antigen_default
image: ubuntu:18.04
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8

68
hetzner/ansible/roles/gantsign.antigen/molecule/default/playbook.yml

@ -0,0 +1,68 @@
---
- name: Converge
hosts: all
pre_tasks:
- name: create test users
become: yes
user:
name: '{{ item }}'
home: '/home/{{ item }}'
createhome: yes
with_items:
- test_usr1
- test_usr2
- test_usr3
- name: install console-setup file
become: yes
copy:
src: tests/console-setup.sh
dest: /etc/default/console-setup
force: no
owner: root
group: root
mode: 'u=rwx,go=r'
roles:
- role: ansible_role_antigen
users:
- username: test_usr1
antigen_libraries:
- name: oh-my-zsh
antigen_theme:
name: robbyrussell
antigen_bundles:
- name: git
- name: ant
url: robbyrussell/oh-my-zsh
location: plugins/ant
- username: test_usr2
antigen_libraries:
- name: prezto
args:
- '--verbose'
env:
ENV_TEST1: 'testValue1'
antigen_theme:
name: testTheme1
url: https://example.com/testTeme1.git
antigen_bundles:
- name: mvn
args:
- '--no-local-clone'
env:
ENV_TEST2: 'testValue2'
- name: gradle
url: https://example.com/gradle.git
branch: master
tag: '1.0'
args:
- '--no-local-clone'
env:
ENV_TEST3: 'testValue3'
- name: sdkman
url: '$HOME/.sdkman-zsh'
- name: escape
url: 't\e"s"ti\ng`pwd`test2$(pwd)'
- username: test_usr3

16
hetzner/ansible/roles/gantsign.antigen/molecule/default/tests/console-setup.sh

@ -0,0 +1,16 @@
# CONFIGURATION FILE FOR SETUPCON
# Consult the console-setup(5) manual page.
ACTIVE_CONSOLES="/dev/tty[1-6]"
CHARMAP="ISO-8859-1"
CODESET="Lat15"
FONTFACE="VGA"
FONTSIZE="8x16"
VIDEOMODE=
# The following is an example how to use a braille font
# FONT='lat9w-08.psf.gz brl-8x8.psf'

272
hetzner/ansible/roles/gantsign.antigen/molecule/default/tests/test_role.py

@ -0,0 +1,272 @@
import pytest
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
@pytest.mark.parametrize('username', [
'test_usr1',
'test_usr2',
])
def test_antigen_install(host, username):
antigen = host.file('/home/' + username + '/.antigen')
assert antigen.exists
assert antigen.is_directory
assert antigen.user == username
assert antigen.group in [username, 'users']
@pytest.mark.parametrize('username', [
'test_usr1',
'test_usr2',
])
def test_antigen_install_file(host, username):
antigen = host.file('/home/' + username + '/.antigen/antigen.zsh')
assert antigen.exists
assert antigen.is_file
assert antigen.user == username
@pytest.mark.parametrize('username', [
'test_usr1',
'test_usr2',
])
def test_oh_my_zsh_install(host, username):
antigen = host.file('/home/' + username +
'/.antigen/bundles/robbyrussell/oh-my-zsh')
assert antigen.exists
assert antigen.is_directory
assert antigen.user == username
assert antigen.group in [username, 'users']
@pytest.mark.parametrize('username', [
'test_usr1',
'test_usr2',
])
def test_zsh_config(host, username):
zshrc = host.file('/home/' + username + '/.zshrc')
assert zshrc.exists
assert zshrc.is_file
assert zshrc.user == username
assert zshrc.group in [username, 'users']
assert zshrc.contains('source ~/.antigenrc')
@pytest.mark.parametrize('username', [
'test_usr1',
'test_usr2',
])
def test_antigen_config(host, username):
antigenrc = host.file('/home/' + username + '/.antigenrc')
assert antigenrc.exists
assert antigenrc.is_file
assert antigenrc.user == username
assert antigenrc.group in [username, 'users']
assert antigenrc.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
source $HOME/.antigen/antigen.zsh
for i in ~/.antigen-etc/use.d/*.zsh; do
if [ -r $i ]; then
source $i
fi
done
unset i
for i in ~/.antigen-etc/bundle.d/*.zsh; do
if [ -r $i ]; then
source $i
fi
done
unset i
source ~/.antigen-etc/theme.zsh
antigen apply
'''.strip()
def test_simple_theme_config(host):
theme = host.file('/home/test_usr1/.antigen-etc/theme.zsh')
assert theme.exists
assert theme.is_file
assert theme.user == 'test_usr1'
assert theme.group in ['test_usr1', 'users']
assert theme.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
antigen theme robbyrussell
'''.strip()
def test_sinple_library_config(host):
library = host.file('/home/test_usr1/.antigen-etc/use.d/oh-my-zsh.zsh')
assert library.exists
assert library.is_file
assert library.user == 'test_usr1'
assert library.group in ['test_usr1', 'users']
assert library.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
antigen use oh-my-zsh
'''.strip()
def test_bundle_with_url_config(host):
bundle = host.file('/home/test_usr1/.antigen-etc/bundle.d/git.zsh')
assert bundle.exists
assert bundle.is_file
assert bundle.user == 'test_usr1'
assert bundle.group in ['test_usr1', 'users']
assert bundle.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
antigen bundle \
--url=git
'''.strip()
def test_bundle_with_location_config(host):
bundle = host.file('/home/test_usr1/.antigen-etc/bundle.d/ant.zsh')
assert bundle.exists
assert bundle.is_file
assert bundle.user == 'test_usr1'
assert bundle.group in ['test_usr1', 'users']
assert bundle.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
antigen bundle \
"--url=robbyrussell/oh-my-zsh" \
--loc=plugins/ant
'''.strip()
def test_theme_with_url_config(host):
theme = host.file('/home/test_usr2/.antigen-etc/theme.zsh')
assert theme.exists
assert theme.is_file
assert theme.user == 'test_usr2'
assert theme.group in ['test_usr2', 'users']
assert theme.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
antigen theme https://example.com/testTeme1.git
'''.strip()
def test_advanced_library_config(host):
library = host.file('/home/test_usr2/.antigen-etc/use.d/prezto.zsh')
assert library.exists
assert library.is_file
assert library.user == 'test_usr2'
assert library.group in ['test_usr2', 'users']
assert library.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
ENV_TEST1=testValue1
antigen use prezto \
--verbose
'''.strip()
def test_bundle_with_args_and_env_config(host):
bundle = host.file('/home/test_usr2/.antigen-etc/bundle.d/mvn.zsh')
assert bundle.exists
assert bundle.is_file
assert bundle.user == 'test_usr2'
assert bundle.group in ['test_usr2', 'users']
assert bundle.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
ENV_TEST2=testValue2
antigen bundle \
--url=mvn \
--no-local-clone
'''.strip()
def test_bundle_with_tag_config(host):
bundle = host.file('/home/test_usr2/.antigen-etc/bundle.d/gradle.zsh')
assert bundle.exists
assert bundle.is_file
assert bundle.user == 'test_usr2'
assert bundle.group in ['test_usr2', 'users']
assert bundle.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
ENV_TEST3=testValue3
antigen bundle \
"--url=https://example.com/gradle.git" \
--branch=1.0 \
--no-local-clone
'''.strip()
def test_bundle_with_env_in_value(host):
bundle = host.file('/home/test_usr2/.antigen-etc/bundle.d/sdkman.zsh')
assert bundle.exists
assert bundle.is_file
assert bundle.user == 'test_usr2'
assert bundle.group in ['test_usr2', 'users']
assert bundle.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
antigen bundle \
"--url=$HOME/.sdkman-zsh"
'''.strip()
def test_bundle_url_escaping(host):
bundle = host.file('/home/test_usr2/.antigen-etc/bundle.d/escape.zsh')
assert bundle.exists
assert bundle.is_file
assert bundle.user == 'test_usr2'
assert bundle.group in ['test_usr2', 'users']
assert bundle.content_string.strip() == r'''
#
# Ansible managed: Do NOT edit this file manually!
#
antigen bundle \
"--url=t\\e\"s\"ti\\ng\`pwd\`test2\$(pwd)"
'''.strip()
def test_console_setup(host):
# console-setup is Debian family specific
if host.file('/etc/debian_version').exists:
setup = host.file('/etc/default/console-setup')
assert setup.exists
assert setup.is_file
assert setup.user == 'root'
assert setup.group == 'root'
assert setup.contains('CHARMAP="UTF-8"')

14
hetzner/ansible/roles/gantsign.antigen/molecule/fedora/Dockerfile.j2

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

26
hetzner/ansible/roles/gantsign.antigen/molecule/fedora/INSTALL.rst

@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
Ansible < 2.6
.. code-block:: bash
$ sudo pip install docker-py
Ansible >= 2.6
.. code-block:: bash
$ sudo pip install docker

29
hetzner/ansible/roles/gantsign.antigen/molecule/fedora/molecule.yml

@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ansible_role_antigen_fedora
image: fedora:28
provisioner:
name: ansible
playbooks:
converge: ../default/playbook.yml
lint:
name: ansible-lint
scenario:
name: fedora
verifier:
name: testinfra
directory: ../default/tests/
lint:
name: flake8

14
hetzner/ansible/roles/gantsign.antigen/molecule/opensuse/Dockerfile.j2

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

26
hetzner/ansible/roles/gantsign.antigen/molecule/opensuse/INSTALL.rst

@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
Ansible < 2.6
.. code-block:: bash
$ sudo pip install docker-py
Ansible >= 2.6
.. code-block:: bash
$ sudo pip install docker

29
hetzner/ansible/roles/gantsign.antigen/molecule/opensuse/molecule.yml

@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ansible_role_antigen_opensuse
image: opensuse/leap:15.0
provisioner:
name: ansible
playbooks:
converge: ../default/playbook.yml
lint:
name: ansible-lint
scenario:
name: opensuse
verifier:
name: testinfra
directory: ../default/tests/
lint:
name: flake8

14
hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_max/Dockerfile.j2

@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

26
hetzner/ansible/roles/gantsign.antigen/molecule/ubuntu_max/INSTALL.rst

@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
Ansible < 2.6
.. code-block:: bash
$ sudo pip install docker-py