Setup Project Directories and Install Ansible

Clone the Git repositories and install Ansible and Ansible Galaxy Roles and Collections.

Projects: c2platform/ansible


Customize ~/.bashrc

Enhance your ~/.bashrc file with the following additions:

export GIT_USER='tclifton'
export GIT_MAIL='tony.clifton@dev.c2platform.org'
alias python='python3'
alias pip='pip3'
alias c2-env='source ~/.virtualenv/c2d/bin/activate'
alias c2-home='cd ~/git/gitlab/c2/ansible-dev'
alias c2='c2-home && c2-env'
alias c2-roles='c2 && ansible-galaxy install -r roles/requirements.yml --force --no-deps -p roles/external'
alias c2-collections='c2 && ansible-galaxy collection install -r collections/requirements.yml -p .'
export C2_HTTPS_SSH=https  # ssh

If you want to use SSH and not HTTPS to access the GitLab Git repositories you should change the line for C2_HTTPS_SSH for SSH access:

export C2_HTTPS_SSH=ssh

If you intend to contribute changes you should add a line that will enable the ansible-lint and yamllint linters to run by creating a pre-commit hook:

export C2_LINTERS=Y

For additional information on linters refer to:

Clone Projects

Utilize the clone.sh script to set up project directories:

sudo apt install git curl -y
curl -s -L https://gitlab.com/c2platform/ansible/-/raw/master/clone.sh | bash

Set Up Python Virtual Environment

Create a Python 3 virtual environment for Ansible for stability and flexibility:

sudo apt update
sudo apt install virtualenv -y
mkdir ~/.virtualenv
DEB_PYTHON_INSTALL_LAYOUT='deb' virtualenv ~/.virtualenv/c2d -p python3

Install Ansible

Install Ansible in the virtual environment c2d:

source ~/.bashrc
c2
pip install -r requirements.txt

Install Ansible Collections / Roles

Utilize the c2-roles and c2-collections aliases to install Ansible Collections and Roles:

c2-roles
c2-collections

Additional Information



Last modified November 13, 2024: translate false C2-587 (af41e45)