the working environment

My workstation is a Fedora 30.
But this should work everywhere you have access to python.

1. Your working directory

Create a working directory:

[workstation] ~/
$ mkdir demo_big_infra

[workstation] ~/
$ cd demo_big_infra

2. Virtualenv

Create a virtualenv:

[workstation] ~/demo_big_infra
$ python3 -m virtualenv ansible_virtualenv

[workstation] ~/demo_big_infra
$ source ansible_virtualenv/bin/activate

Don’t forget to activate the virtualenv if you left your active session.

3. Download the Ansible Playbooks

We will use 3 projects:

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ git clone https://git.t18s.fr/ansible-playbooks/infrasecrets.git
$ cd infrasecrets
$ git checkout 1.0
$ cd ..

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ git clone https://git.t18s.fr/ansible-playbooks/echo.git
$ cd echo
$ git checkout 1.0
$ cd ..

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ git clone https://git.t18s.fr/ansible-playbooks/system.git
$ cd system
$ git checkout 1.0
$ cd ..

4. Download the required python modules

This will install Ansible 2.7 and all required modules.

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ pip install -r infrasecrets/requirements_pip.txt

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ pip install -r system/requirements_pip.txt

The echo project will not be launched from here, so we don’t need its modules.

5. Download the Ansible Roles

This will download the required roles for each projects.

[workstation] (ansible_virtualenv) ~/demo_big_infra 
$ cd infrasecrets
$ ansible-galaxy install -r requirements_galaxy.yml
$ cd ..

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ cd system
$ ansible-galaxy install -r requirements_galaxy.yml
$ cd ..

The echo project will not be launched from here, so we don’t need its roles.

6. Put the API Keys and Tokens in your environment

Export the API Keys and Tokens you generated before.

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ export AWS_ACCESS_KEY_ID=CHANGE_WITH_KEY_ID
$ export AWS_SECRET_ACCESS_KEY=CHANGE_WITH_SECRET_KEY
$ export CLOUDFLARE_EMAILCLOUDFLARE_EMAIL=CHANGE_WITH_EMAIL
$ export CLOUDFLARE_TOKEN=CHANGE_WITH_TOKEN

Don’t forget to re-export them if you left your active session.

7. Create a SSH key

You will need a SSH key:

[workstation] (ansible_virtualenv) ~/demo_big_infra
$ ssh-keygen -t ed25519 -f ~/.ssh/demo_big_infra

8. Next page!

We are done, let’s go configuring the infrastructure.