andrelohmann.odoo
Odoo
Overview
Use this setup to install the latest version of Odoo from the source on your Ubuntu server.
Requirements
This setup only works on Ubuntu.
Configuration Variables
You can set the following variables to customize Odoo:
odoo_release: latest # Example: 16, 17
odoo_source_install: false # Change to true to install from nightly packages
odoo_config: [] # Settings for Odoo
# Add configuration parameters like this:
# - key: db_name
# value: odoo
# - key: admin_passwd
# value: S3cr3t!
odoo_init_databases: [] # Initialize databases if needed
# - database: odoo_1
# language: de_DE
Example Playbook
- hosts: odoo
become: yes
roles:
- { role: andrelohmann.odoo }
Role Development
Special Features
This setup supports various development tools:
- yamllint
- ansible-lint
- molecule for testing
- GitHub Actions
- Automatic version updates
- Update ansible-galaxy
- Show build status
- Test with Vagrant (for development)
- Test with Molecule (inside or outside Vagrant)
- Develop and test in Visual Studio Code
Prerequisites
For detailed setup instructions, visit: https://thedatabaseme.de/2022/01/17/automated-testing-your-ansible-role-with-molecule-and-github-actions/
You’ll need:
- VirtualBox + Vagrant (if testing with Vagrant)
- Docker Desktop
- Visual Studio Code + remote extension pack (dependencies in
.vscode/extensions.json
)
Development Setup
This role is developed and tested using Molecule, Visual Studio Code, and a development container for tool dependencies (like Ansible and linters).
The role will be tested on Ubuntu.
To run tests, bind mount the Docker socket into the development container.
Important Files and Folders
.devcontainer
- Contains the Dockerfile for the development container
- Configures startup procedures (like Docker socket mounting)
molecule/default/Dockerfile.js
- Template for all platforms listed in
molecule/default/molecule.yml
- Prepares environments for systemd services (needed for some Ansible roles)
- Installs all requirements for running Ansible in the container
- Matches platform attributes in
molecule/default/molecule.yml
Usage
In Visual Studio Code
- Go to the root directory of your role and open VS Code:
code .
- In the development container, run the following commands:
yamllint .
ansible-lint .
molecule create
molecule test --all
Using Vagrant + VirtualBox
- Navigate to your role's root directory.
- Go to the Vagrant folder.
- Start and access the Vagrant machine:
vagrant up
vagrant ssh
- Navigate to the role folder:
cd /etc/ansible/roles/ansible-role-[tab]
- Now you can run all tests:
yamllint .
ansible-lint .
molecule create
molecule test --all
Build and Release Process
The Ansible role includes GitHub workflows for testing and releasing.
Protecting the main branch
- Go to Settings -> Branches -> Add branch protection rule.
- Set branch pattern to
main
ormaster
. - Check "Require a pull request before merging."
- Set "Require approvals" as needed.
Allow read/write permissions for GITHUB_TOKEN
- Go to Settings -> Actions -> General -> Workflow permissions.
- Set it to read and write.
Commit Message Guidelines
Follow this format for commit messages to trigger version updates:
patch
0.0.x
fix(single_word): description
minor
0.x.0
feat(single_word): description
major
x.0.0
perf(single_word): description
BREAKING CHANGE: description of the breaking change
Make sure "BREAKING CHANGE:" is on the second line or later. Single-line messages won't trigger major updates.
Adding GALAXY_API_KEY Secret
- Log in to your GitHub account at https://galaxy.ansible.com/.
- Get the Galaxy API key from Preferences -> API Key.
- Go to your GitHub repository.
- Navigate to Settings -> Secrets and variables -> Actions -> New repository secret.
- Use "GALAXY_API_KEY" as the key and paste the Galaxy API key as the value.
License
MIT
Author Information
© Andre Lohmann (and others) 2024
Maintainer Contact
- Andre Lohmann lohmann.andre@gmail.com
ansible-galaxy install andrelohmann.odoo