Newer
Older
This ansible-role for dealing with installing the dependencies for deploying the system used from **c3infodesk**.
## Mentions
This role uses great part of it from [geerlingguy](https://github.com/geerlingguy) for installing **docker** at the target host.
The original code used can be found at: [https://github.com/geerlingguy/ansible-role-docker](https://github.com/geerlingguy/ansible-role-docker)
## Requirements
- To have [ansible](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html) installed at your system.
## Configuration
You need to set some configuration for this to work
- ### ansible.cfg
You have to edit the **ansible.cfg** file to your needs for accessing your target.
- #### remote_user
You need to set the **remote_user** configuration for accessing the target host.
Example: [remote_user](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/ansible.cfg#L227)
- ### HOST_VARS
In order to access your target host, you need to create/edit your **inventories/host_vars/<YOUR_HOST_NAME>.yml**
- #### ansible_become_pass
You need to set the **sudo** password from the user setted on **remote_user** for installing packages and etc. at the target.
Example: [ansible_become_pass](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/host_vars/example_server.yml#L5)
- ### HOSTS
You need to provide a **group** in which your target belongs to with the same name setted for **inventories/host_vars/<YOUR_HOST_NAME>.yml**.
Example: [hosts](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/hosts)
- ### From: inventories/host_vars/<TARGET_NAME>
Here are the variables that you should be changing for your own deployment.
- **docker_users**: DEFAULT="[test-user]"
- The users to be added to the docker group.
- These users should should contain at least the same user setted on **ansible.cfg** at the **remote_user**
- **ansible_become_pass**: DEFAULT="Please change this"
- The password used from the user setted on **ansible.cfg** at the **remote_user**
- ### From: inventories/group_vars/<TARGET_GROUP>
This role needs no variable setted on **group_vars**
- ### From: roles/clone-repositories/defaults/main.yml
Here are the variables used for this role. Please don't change then here but instead in **inventories/host_vars/<TARGET_NAME>**
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
- **docker_users**
- **ansible_become_pass**
- **os_dependencies_packages**
- **docker_edition**
- **docker_packages**
- **docker_packages_state**
- **docker_obsolete_packages**
- **docker_obsolete_packages**
- **docker_service_manage**
- **docker_service_state**
- **docker_service_enabled**
- **docker_restart_handler_state**
- **docker_install_compose_plugin**
- **docker_compose_package**
- **docker_compose_package_state**
- **docker_install_compose**
- **docker_compose_version**
- **docker_compose_arch**
- **docker_compose_url**
- **docker_compose_path**
- **docker_add_repo**
- **docker_apt_release_channel**
- **docker_apt_ansible_distribution**
- **docker_apt_arch**
- **docker_apt_repository**
- **docker_apt_ignore_key_error**
- **docker_apt_gpg_key**
- **docker_apt_gpg_key_checksum**
- **docker_apt_filename**
- **docker_yum_repo_url**
- **docker_yum_repo_enable_nightly**
- **docker_yum_repo_enable_test**
- **docker_yum_gpg_key**
- **docker_daemon_options**
- ### From: roles/dependencies/vars/main.yml
- **docker_packages**
- **docker_compose_package**
## Dependencies
This role have no dependency from any another role.
- ### Using the provided example
For using the example playbook **[playbooks/examples/example_02_dependencies.yml](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/playbooks/examples/example_02_dependencies.yml)** file you only need to:
- Change the user at the **[ansible.cfg](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/ansible.cfg)** file at the field **[remote_user](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/ansible.cfg#L227)** for acessing your target.
- Update the file **[inventories/host_vars/example_server.yml](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/host_vars/example_server.yml)** and change the value for **[ansible_become_pass](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/host_vars/example_server.yml#L5)** from the **[remote_user](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/ansible.cfg#L227)**
- Update the **[inventories/hosts](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/hosts)** file and change the **[example_server](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/hosts#L2)** with the IP address from your target.
And run the command:
```bash
ansible-playbook -i inventories/hosts playbooks/examples/example_02_dependencies.yml
```
- ### Setting your own example
After setting your variables at **inventories/host_vars/<HOST_NAME>**, you can add this role to your playbook as a regular role.
Here is an example using the **<HOST_NAME>** as **test_servers**
```yaml
- hosts:
- test_servers
roles:
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
```
And call the playbook as:
```bash
ansible-playbook -i <INVENTORY> <PLAYBOOK_NAME>.yml
```
## Testing
You can test this locally using **DIND (docker in docker)** at your own computer using [ansible molecule](https://ansible.readthedocs.io/projects/molecule/installation/)
- ### Testing requirements
You need docker installed at your system and the [ansible molecule](https://ansible.readthedocs.io/projects/molecule/installation/).
You might have to set DIND at your system, for linux, you can create the file **/etc/docker/daemon.json**
And add the content and restart docker.
```json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"features": {
"buildkit": true
},
"experimental": true,
"cgroup-parent": "docker.slice"
}
```
- ### Using molecule
Just go to the root of the role **roles/dependencies** and run the command:
```bash
molecule test
```