Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Robert committed Sep 29, 2022
1 parent 64a6a85 commit 87ef197
Show file tree
Hide file tree
Showing 17 changed files with 656 additions and 0 deletions.
213 changes: 213 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,ansible,python
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,ansible,python

### Ansible ###
*.retry

### 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*

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# Support for Project snippet scope
.vscode/*.code-snippets

# Ignore code-workspaces
*.code-workspace

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,ansible,python

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

33 changes: 33 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Based on ansible-lint config
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# bootstrap

[![Ansible version](https://img.shields.io/badge/ansible-%3E%3D2.10-black.svg?style=flat-square&logo=ansible)](https://github.com/ansible/ansible)

⭐ Star us on GitHub — it motivates us a lot!

your role description

**Platforms Supported**:

None.

## ⚠️ Requirements

Ansible >= 2.1.

### Ansible role dependencies

None.

## ⚡ Installation

### Install with Ansible Galaxy

```shell
ansible-galaxy install bootstrap
```

### Install with git

If you do not want a global installation, clone it into your `roles_path`.

```bash
git clone bootstrap
```

But I often add it as a submodule in a given `playbook_dir` repository.

```bash
git submodule add roles/bootstrap
```

As the role is not managed by Ansible Galaxy, you do not have to specify the
github user account.

### ✏️ Example Playbook

Basic usage is:

```yaml
- hosts: all
roles:
- role: bootstrap
vars:
bootstrap_timeout: 10

```
## ⚙️ Role Variables
Variables are divided in three types.
The **default vars** section shows you which variables you may
override in your ansible inventory. As a matter of fact, all variables should
be defined there for explicitness, ease of documentation as well as overall
role manageability.
The **context variables** are shown in section below hint you
on how runtime context may affects role execution.
### Default variables
#### main
Bootsrap a machine for Ansible.
| Variable Name | Required | Type | Default | Elements | Description |
|---------------|----------|------|---------|----------|-------------|
| bootstrap_timeout | False | int | 10 | | |
### Context variables
Those variables from `vars/*.{yml,json}` are loaded dynamically during task
runtime using the `include_vars` module.

Variables loaded from `vars/main.yml`.

| Variable Name | Value |
|---------------|-------|
| bootstrap_os_family_map | Alpine:<br>- Alpine<br>Archlinux:<br>- Archlinux<br>- Antergos<br>- Manjaro<br>Debian:<br>- Debian<br>- Ubuntu<br>- Raspbian<br>- Neon<br>- KDE neon<br>- Linux Mint<br>- SteamOS<br>- Devuan<br>- Kali<br>- Cumulus Linux<br>- Pop!_OS<br>- Parrot<br>- Pardus GNU/Linux<br>Gentoo:<br>- Gentoo<br>- Funtoo<br>RedHat:<br>- RedHat<br>- Fedora<br>- CentOS<br>- Scientific<br>- SLC<br>- Ascendos<br>- CloudLinux<br>- PSBM<br>- Rocky<br>- OracleLinux<br>- OVS<br>- OEL<br>- Amazon<br>- Virtuozzo<br>- XenServer<br>- Alibaba<br>- EulerOS<br>- openEuler<br>- AlmaLinux<br>Suse:<br>- SLED<br>- openSUSE Tumbleweed<br>- openSUSE Leap<br>- SLES_SAP<br>- SUSE_LINUX<br>- SLES<br>- openSUSE<br>- SuSE<br> |
| bootstrap_install | {{ _bootstrap_install[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version] \|default( _bootstrap_install[bootstrap_distribution] ) \|default( _bootstrap_install[bootstrap_os_family] ) }} |
| _bootstrap_install | Alpine:<br> raw: LANG=C apk update ; apk add {{ bootstrap_packages }}<br> stdout_regex: Installing<br>Archlinux:<br> raw: LANG=C pacman -Sy --noconfirm {{ bootstrap_packages }}<br> stdout_regex: ' installing python'<br>Debian:<br> raw: LANG=C apt-get update && apt-get install -y {{ bootstrap_packages }}<br> stdout_regex: ' 0 newly installed'<br>Gentoo:<br> raw: LANG=C equery l {{ bootstrap_packages }} \| \| (emaint -a sync ; emerge -qkv {{<br> bootstrap_packages }} ; echo 'changed')<br> stdout_regex: changed<br>RedHat:<br> raw: LANG=C yum -y install {{ bootstrap_packages }}<br> stdout_regex: Nothing<br>Suse:<br> raw: LANG=C zypper -n install {{ bootstrap_packages }}<br> stdout_regex: Nothing<br> |
| _bootstrap_packages | Alpine: python3 sudo<br>Amazon: python sudo<br>Archlinux: python sudo<br>CentOS_7: python sudo<br>Debian: python3 sudo gnupg python3-apt<br>Debian_8: python sudo gnupg<br>Debian_9: python sudo gnupg<br>Gentoo: python sudo gentoolkit<br>RedHat: python3 sudo<br>RedHat_7: python sudo<br>Suse: python3 python3-xml sudo<br> |
| bootstrap_packages | {{ _bootstrap_packages[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version] \|default( _bootstrap_packages[bootstrap_distribution] ) \|default( _bootstrap_packages[bootstrap_os_family] ) }} |
| bootstrap_facts_packages | {{ _bootstrap_packages[ansible_distribution ~'_'~ ansible_distribution_major_version] \|default( _bootstrap_packages[ansible_distribution] ) \|default( _bootstrap_packages[ansible_os_family] ) }} |



## Author Information

your company (optional)
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
bootstrap_timeout: 10
2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for stephrobert.bootstrap
12 changes: 12 additions & 0 deletions meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
argument_specs:
main:
short_description: "Bootsrap a machine for Ansible."
description: >
Install minimal package to allow Ansible to manage Hosts.
author: Stephane ROBERT
options:
bootstrap_timeout:
type: int
default: 10
description: "Time (in seconds) to wait for connection."
22 changes: 22 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
galaxy_info:
author: Stéphane ROBERT
description: Prepare your system to be managed by Ansible.
company: none
license: MPL-2.0
min_ansible_version: "2.12"
platforms:
- name: Fedora
versions:
- "35"
- "36"
- name: Ubuntu
versions:
- "jammy"
- name: Debian
versions:
- "bullseye"
galaxy_tags:
- python
- ansible
- sudo
dependencies: []
Loading

0 comments on commit 87ef197

Please sign in to comment.