Skip to content
Snippets Groups Projects
README.md 6.85 KiB
Newer Older
fejao's avatar
fejao committed
# docker_images role
fejao's avatar
fejao committed

fejao's avatar
fejao committed
This ansible-role for dealing with creating the docker images necessary for deploying the system used from **c3infodesk**.

## Requirements
- To have [ansible](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html) installed at your system.
fejao's avatar
fejao committed


fejao's avatar
fejao committed
## 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.
fejao's avatar
fejao committed

fejao's avatar
fejao committed
    Example: [remote_user](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/ansible.cfg#L227)
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### 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.
fejao's avatar
fejao committed

fejao's avatar
fejao committed
    Example: [ansible_become_pass](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/host_vars/example_server.yml#L5)
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### 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**.
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  There you can add/edit the target address/IP.
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  Example: [hosts](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/inventories/hosts)
fejao's avatar
fejao committed


fejao's avatar
fejao committed
## Role Variables
Here are the variables setted:
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### From: inventories/host_vars/<TARGET_NAME>
  Here are the variables that you should be changing for your own deployment.
  - **c3infodesk_printer_debug_create_image_cups**: DEFAULT=<NOT_SETTED>
    - If you want to debug the output from creating the image for CUPS
  - **c3infodesk_printer_debug_create_image_app**: DEFAULT=<NOT_SETTED>
    - If you want to debug the output from creating the image for the APP
  - **c3infodesk_printer_debug_create_image_proxy**: DEFAULT=<NOT_SETTED>
    - If you want to debug the output from creating the image for the PROXY
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### From: inventories/group_vars/<TARGET_GROUP>
  Please don't cahnge the default values at this file. If you need to update them, use the **inventories/host_vars/<TARGET_NAME>** file.
  - **c3infodesk_printer_folder_docker**: DEFAULT="Coding/c3infodesk-printer/docker"
    - The folder where the configuration from docker used for the system
  - **c3infodesk_printer_folder_docker_cups**: DEFAULT="Coding/c3infodesk-printer/docker/cups"
    - The folder where the configuration from docker CUPS used for the system
  - **c3infodesk_printer_folder_docker_app**: DEFAULT="Coding/c3infodesk-printer/docker/app"
    - The folder where the configuration from docker APP used for the system
  - **c3infodesk_printer_folder_docker_proxy**: DEFAULT="Coding/c3infodesk-printer/docker/proxy"
    - The folder where the configuration from docker PROXY used for the system
  - **c3infodesk_printer_docker_img_cups_name**: DEFAULT="c3printing-cups"
    - The name of the image to be set for the CUPS
  - **c3infodesk_printer_docker_img_cups_tag**: DEFAULT="latest"
    - The tag name/number to be setted for the CUPS image
  - **c3infodesk_printer_docker_img_app_name**: DEFAULT="c3printing-app"
    - The name of the image to be set for the APP
  - **c3infodesk_printer_docker_img_app_tag**: DEFAULT="latest"
    - The tag name/number to be setted for the APP image
  - **c3infodesk_printer_docker_img_proxy_name**: DEFAULT="c3printing-proxy"
    - The name of the image to be set for the PROXY
  - **c3infodesk_printer_docker_img_proxy_tag**: DEFAULT="latest"
    - The tag name/number to be setted for the PROXY image
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### From: roles/clone-repositories/defaults/main.yml
  Don't change the values at this file, if you need to change them, change it at the **inventories/host_vars/<TARGET_NAME>** file
  - **c3infodesk_printer_debug_create_image_cups**: DEFAULT=false
  - **c3infodesk_printer_debug_create_image_app**: DEFAULT=false
  - **c3infodesk_printer_debug_create_image_proxy**: DEFAULT=false
fejao's avatar
fejao committed


fejao's avatar
fejao committed
## Dependencies
The role dependencies are:
fejao's avatar
fejao committed
  - [dependencies(role)](https://git.cccv.de/fejao/c3infodesk-deployment-role-dependencies)
  - [clone_repositories](https://git.cccv.de/fejao/c3infodesk-deployment-role-clone-repositories)
fejao's avatar
fejao committed


fejao's avatar
fejao committed
## Example Playbook
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### Using the provided example
    For using the example playbook **[playbooks/examples/example_04_docker_images.yml](https://git.cccv.de/fejao/c3infodesk-deployment/-/blob/main/playbooks/examples/example_04_docker_images.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.
fejao's avatar
fejao committed


fejao's avatar
fejao committed
    And run the command:
  ```bash
  ansible-playbook -i inventories/hosts playbooks/examples/example_04_docker_images.yml
  ```
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### 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.
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  Here is an example using the **<HOST_NAME>** as **test_servers**
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  ```yaml
  - hosts:
      - test_servers
    roles:
fejao's avatar
fejao committed
      - roles/c3infodesk-deployment-role-docker-images
fejao's avatar
fejao committed
  ```
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  And call the playbook as:
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  ```bash
  ansible-playbook -i <INVENTORY> <PLAYBOOK_NAME>.yml
  ```
fejao's avatar
fejao committed


fejao's avatar
fejao committed
## 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/)
fejao's avatar
fejao committed

fejao's avatar
fejao committed
- ### Testing requirements
  You need docker installed at your system and the [ansible molecule](https://ansible.readthedocs.io/projects/molecule/installation/).
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  You might have to set DIND at your system, for linux, you can create the file **/etc/docker/daemon.json**
fejao's avatar
fejao committed

fejao's avatar
fejao committed
  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
  ```
fejao's avatar
fejao committed


## License

fejao's avatar
fejao committed
MIT / BSD


## Author Information
[https://chaos.social/@fejao](https://chaos.social/@fejao)