Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use with multiple server Trellis #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ Install [New Relic PHP agent](https://docs.newrelic.com/docs/agents/php-agent) o
## Role Variables

```yaml
# group_vars/<environment>/vault.yml
# group_vars/<environment>/vault.yml or host_vars/<host>/vault.yml
# This file should be encrypted. See: https://roots.io/trellis/docs/vault/
##########################################################################

# New Relic License Key
## See: https://docs.newrelic.com/docs/accounts-partnerships/accounts/account-setup/license-key
# vault_newrelic_license: false
vault_newrelic_license: xxxxxxxxxxx

# group_vars/<environment>/main.yml
Expand Down Expand Up @@ -105,6 +106,10 @@ Add this role to `requirements.yml`:

Run `$ ansible-galaxy install -r requirements.yml` to install this new role.

## Multiple servers

As an alternative to setting the license key for an environment under `group_vars` you can set it for a single server under `host_vars`. You can explicitly set `false` to skip a group or host, or omit the variable from the vault file. A warning will be shown when setup is skipped.

## Common Errors

### `vault_newrelic_license` is not defined
Expand Down
4 changes: 3 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
newrelic_package_state: latest

newrelic_license: "{{ vault_newrelic_license | default(false) }}"

newrelic_config_default:
license: "{{ vault_newrelic_license }}"
license: "{{ newrelic_license }}"
appname: "{{ wordpress_sites.keys() | first }} {{ env }}"
framework: wordpress
logfile: /var/log/newrelic/php_agent.log
Expand Down
11 changes: 7 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
---
- name: Fail if vault_newrelic_license is not defined
fail:
msg: vault_newrelic_license is not defined
when: vault_newrelic_license is not defined
- name: Warn if vault_newrelic_license is not defined
debug:
msg: |
Note: Skipping New Relic tasks. vault_newrelic_license is not set. Make sure this is set in vault.yml.
when: newrelic_license == false

- include: install.yml
when: newrelic_license != false
- include: ini.yml
when: newrelic_license != false