Skip to content
Snippets Groups Projects
fejao's avatar
fejao authored
Updated the README.md file

See merge request !2
64a5cf11
History

clone_repositories role

This ansible-role for dealing with cloning the repositories necessary for deploying the system used from c3infodesk.

Requirements

  • To have ansible 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

  • 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

  • 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.

    There you can add/edit the target address/IP.

    Example: hosts

Role Variables

Here are the variables setted:

  • From: inventories/host_vars/<TARGET_NAME>

    Here are the variables that you should be changing for your own deployment.

    • c3infodesk_printer_repo_new_branch_name: DEFAULT="test_branch"
      • The branch name that it will be checked-out for avoiding updating the main branch
  • From: inventories/group_vars/<TARGET_GROUP>

    • c3infodesk_printer_folder: DEFAULT="Coding/c3infodesk-printer"
      • The folder where to clone the repositories
  • From: roles/clone-repositories/defaults/main.yml

    • c3infodesk_printer_repo_clone: DEFAULT=true
      • If it should or not clone the repository.
    • c3infodesk_printer_repo_url: DEFAULT="https://git.cccv.de/fejao/c3infodesk-printer.git"
      • The repository to be cloned.
    • c3infodesk_printer_repo_new_branch_name: DEFAULT="new_branch_name"
      • The branch name to be set after cloning the repository.

Dependencies

The role dependencies are:

Example Playbook

  • Using the provided example

    For using the example playbook playbooks/examples/example_03_clone_repositories.yml file you only need to:

    And run the command:

    ansible-playbook -i inventories/hosts playbooks/examples/example_03_clone_repositories.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

    - hosts:
        - test_servers
      roles:
        - roles/clone_repositories

    And call the playbook as:

    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

  • Testing requirements

    You need docker installed at your system and the ansible molecule.

    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.

    {
      "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:

    molecule test

License

MIT / BSD

Author Information

https://chaos.social/@fejao