Skip to content

Ansible setup

Angel Rey edited this page Dec 23, 2020 · 1 revision

Install Ansible

You need to add the repository for installing the ansible latest version.

sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible

Clone the code

# Clone the code in your /opt directory
cd ~
git clone https://github.com/Monadical-SAS/oddslingers.poker
sudo mv oddslingers.poker /opt
cd /opt/oddslingers.poker

Run the playbook

It is important to remember that Ansible is a python supported software and its version is important. It is recommended to install python3 for running the playbook.

The playbook has some vars you need to pass in the command line:

  • sudo_user: User with root permissions.
  • db_name: Name for oddslingers database.
  • db_user: Database user for oddslingers database.
  • db_password: Database password for oddslingers database.
  • oddslingers_root: Oddslingers path. Usually, /opt/oddslingers.poker.
  • init_db: true or false. If you had some problem in the installation but the playbook created the database, set to false.

For the database password you can define an env variable with the command:

POSTGRES_PASSWORD=$(openssl rand -base64 14)

For running, execute the command:

sudo ansible-playbook playbook.yml -e 'ansible_python_interpreter=/usr/bin/python3' \
    --extra-vars "sudo_user=username db_name=oddslingers db_user=oddslingers db_password=${POSTGRES_PASSWORD} oddslingers_root=/opt/oddslingers.poker init_db=true"                           

The playbook runs in localhost by default.

Run initial migrations and create superuser

cd /opt/oddslingers.poker/core
pipenv shell
./manage.py migrate
./manage.py createsuperuser

Start oddslingers

You can start oddslingers now by management command.

# For Bash: add this line to ~/.bashrc or ~/.bash_profile
PATH=/opt/oddslingers.poker/bin:./node_modules/.bin:$PATH
# Set `POSTGRES_HOST` to `localhost` in `./env/dev.env` file.
oddslingers start

Then visit the host to see your running development server! Go to https://oddslingers.l and enjoy