-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate files form the legacy doc-guidelines
Those were migrated as is as they are still up to date.
- Loading branch information
Showing
9 changed files
with
2,162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Ansible guidelines | ||
|
||
- [Naming convention](#naming-convention) | ||
- [Linting](#linting) | ||
- [Formatting](#formatting) | ||
- [Role vs Tasks](#role-vs-tasks) | ||
- [Repository Structure](#repository-structure) | ||
- [Collection](#collection) | ||
|
||
## Naming convention | ||
|
||
File, directory and variable names MUST be `snake_case`. Only use `yaml` files and use `*.yml` extension. | ||
|
||
## Linting | ||
|
||
Code should pass linting | ||
|
||
```bash | ||
ansible-lint | ||
``` | ||
|
||
## Formatting | ||
|
||
Code should be formatted as follow: | ||
|
||
- Use space instead of tab | ||
- Use 2 spaces indentation | ||
- YAML files should always start with `---` and end with a blank line | ||
|
||
```yaml | ||
--- | ||
# This is an example of correct yaml file formatted | ||
my_yaml: | ||
content: hello world | ||
|
||
``` | ||
|
||
You should always use the formatting tool of ansible-lint | ||
|
||
```bash | ||
ansible-lint --write all | ||
``` | ||
|
||
## Role vs Tasks | ||
|
||
For reusable code prefer Roles over Tasks. If some code could reused than encapsulate it in a role, | ||
otherwise simply add it to your playbook. | ||
|
||
## Repository Structure | ||
|
||
Repository should be prefixed by; `infra-ansible-` | ||
|
||
And they should follow this structure | ||
|
||
```text | ||
├── files | ||
│ └── some-file.txt | ||
├── group_vars | ||
│ └── group_name.yml | ||
├── hosts_vars | ||
│ └── host_name.yml | ||
├── roles | ||
│ └── my_role | ||
│ ├── handlers | ||
│ │ └── main.yml | ||
│ ├── defaults | ||
│ │ └── main.yml | ||
│ ├── files | ||
│ │ └── some-file.txt | ||
│ ├── tasks | ||
│ │ └── main.yml | ||
│ ├── vars | ||
│ │ └── main.yml | ||
│ └── README.md | ||
├── vars | ||
│ └── main.yml | ||
├── playbook_1.yml | ||
├── playbook_2.yml | ||
└── inventory.yml | ||
``` | ||
|
||
### Collection | ||
|
||
For collection we follow the ansible standard folder structure | ||
|
||
```text | ||
├── roles | ||
│ └── bgdi_toolchains | ||
│ ├── handlers | ||
│ ├── defaults | ||
│ ├── files | ||
│ ├── tasks | ||
│ │ └── main.yml | ||
│ ├── vars | ||
│ └── README.md | ||
├── playbooks | ||
| ├── files | ||
| ├── vars | ||
| ├── templates | ||
│ └── my-playbook.yml | ||
├── galaxy.yml | ||
└── README.md | ||
``` |
Oops, something went wrong.