|
1 | | -# Ansible Role Template |
| 1 | +# Ansible Python Install |
2 | 2 |
|
3 | | -[](https://github.com/Appsilon/ansible-role-template/actions/workflows/ci.yml) |
| 3 | +Install Python from source on Ubuntu-based systems (based on RStudio [docs](https://docs.rstudio.com/resources/install-python-source/)). |
4 | 4 |
|
5 | | -This repository provides a base scaffolding template to use as a quick start of |
6 | | -all Ansible roles at @Appsilon. Includes best practices that should always be |
7 | | -used, like linter, tests, CI, etc. |
| 5 | +[](https://github.com/Appsilon/ansible-python-install/actions/workflows/ci.yml) |
| 6 | +[](https://galaxy.ansible.com/appsilon/ansible-role-template) |
8 | 7 |
|
9 | | -## How to Use |
| 8 | +## Requirements |
10 | 9 |
|
11 | | -1. Click "[Use this |
12 | | - template](https://github.com/Appsilon/ansible-role-template/generate)" to |
13 | | - create a new repository from it. |
14 | | -1. Update [`./meta/main.yml`](./meta/main.yml) with updated repository and role names. |
15 | | -1. Update [`./role_README.md`](./role_README.md) with updated to repository and role name. |
16 | | -1. Rename `./role_README.md` to `README.md`. |
17 | | -1. Start coding! You're free to change anything. |
| 10 | +None. |
18 | 11 |
|
19 | | -## Development |
| 12 | +## Role Variables |
20 | 13 |
|
21 | | -### Dependencies |
| 14 | +| Variable | Required | Default | Choices | Comments | |
| 15 | +|-----------------|----------|------------------|-----------------------------------|---------------------------------------| |
| 16 | +| python_versions | yes | [3.10.6, 3.9.13] | Array with Python versions >= 3.7 | Version have to be specified as 3.x.y | |
22 | 17 |
|
23 | | -To execute tests locally, it is necessary to install the following |
24 | | -dependencies: |
| 18 | +## Dependencies |
25 | 19 |
|
26 | | -* [Python](https://www.python.org/downloads/) |
27 | | -* [Molecule](https://molecule.readthedocs.io/en/latest/installation.html) |
| 20 | +None. |
28 | 21 |
|
29 | | -### Preparing the Environment |
| 22 | +## Example Playbook |
30 | 23 |
|
31 | | -Create a Python environment: |
32 | | - |
33 | | -```bash |
34 | | -python3 -m venv .venv |
35 | | -``` |
36 | | - |
37 | | -Activate the environment: |
38 | | - |
39 | | -```bash |
40 | | -source .venv/bin/activate |
41 | | -``` |
42 | | - |
43 | | -Install molecule (and its dependencies) inside the environment: |
44 | | - |
45 | | -```bash |
46 | | -python3 -m pip install -r requirements.txt |
47 | | -``` |
48 | | - |
49 | | -### Running |
50 | | - |
51 | | -```bash |
52 | | -molecule test |
53 | | -``` |
54 | | - |
55 | | -To perform quick test after some modification: |
56 | | - |
57 | | -```bash |
58 | | -molecule create |
59 | | -molecule converge |
60 | | -molecule verify |
61 | | -``` |
62 | | - |
63 | | -To log into the running instance for troubleshooting purposes: |
64 | | - |
65 | | -```bash |
66 | | -molecule login |
67 | | -``` |
68 | | - |
69 | | -At the end of the test, destroy the environment: |
70 | | - |
71 | | -```bash |
72 | | -molecule destroy |
73 | | -``` |
74 | | - |
75 | | -### Validation, Linters and Pull-Requests |
76 | | - |
77 | | -We want to provide high quality code. For this reason we are using several |
78 | | -[pre-commit hooks](.pre-commit-config.yaml) and [GitHub Actions |
79 | | -workflow](.github/workflows/precommit.yaml). A pull-request to the `main` |
80 | | -branch will trigger these validations and lints automatically. Please check your |
81 | | -code before you will create pull-requests. |
82 | | - |
83 | | -Before you can run hooks, you need to have the `pre-commit` |
84 | | -[installed](https://pre-commit.com#install). |
85 | | - |
86 | | -```bash |
87 | | -pip install pre-commit |
88 | | -pre-commit install |
89 | | -``` |
90 | | - |
91 | | -If you are going to enforce [Conventional |
92 | | -Commits](https://www.conventionalcommits.org/) commit message style on the title |
93 | | -you will also need to |
94 | | -[install](https://jorisroovers.com/gitlint/#getting-started) `gitlint`. |
95 | | - |
96 | | -```bash |
97 | | -pip install gitlint |
98 | | -``` |
99 | | - |
100 | | -You then need to install the pre-commit hook like so: |
101 | | - |
102 | | -```bash |
103 | | -pre-commit install --hook-type commit-msg |
| 24 | +```yaml |
| 25 | +- hosts: all |
| 26 | + vars: |
| 27 | + python_versions: |
| 28 | + - 3.10.6 |
| 29 | + - 3.7.8 |
| 30 | + roles: |
| 31 | + - ansible-python-install |
104 | 32 | ``` |
105 | 33 |
|
106 | | -> It's important that you run `pre-commit install --hook-type commit-msg`, even |
107 | | -> if you've already used `pre-commit install` before. `pre-commit install` does |
108 | | -> not install `commit-msg` hooks by default! |
| 34 | +## License |
109 | 35 |
|
110 | | -To manually trigger `gitlint` using `pre-commit` for your last commit message, |
111 | | -use the following command: |
| 36 | +MIT |
112 | 37 |
|
113 | | -```sh |
114 | | -pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG |
115 | | -``` |
116 | | - |
117 | | -In case you want to change gitlint's behavior, you should either use a |
118 | | -`.gitlint` file (see |
119 | | -[Configuration](https://jorisroovers.com/gitlint/configuration)) or modify the |
120 | | -gitlint invocation in your `.pre-commit-config.yaml` file like so: |
121 | | - |
122 | | -```yaml |
123 | | -- repo: https://github.com/jorisroovers/gitlint |
124 | | - rev: # Fill in a tag / sha here |
125 | | - hooks: |
126 | | - - id: gitlint |
127 | | - args: [--contrib=CT1, --msg-filename] |
128 | | -``` |
| 38 | +## Author Information |
129 | 39 |
|
130 | | -See [pre-commit documentation](https://pre-commit.com/) and [GitHub Actions |
131 | | -documentation](https://docs.github.com/en/actions) for further details. |
| 40 | +[`Appsilon`](https://appsilon.com/) |
0 commit comments