Skip to content

Commit

Permalink
feat: allow user defined RESOURCE_NAMESPACE (#54)
Browse files Browse the repository at this point in the history
If the uniqueness of `molecule_scenario_directory` is not enough, one
can override the RESOURCE_NAMESPACE variable to provide their own value.
For example, this can prevent collisions with duplicate CI workflows.
  • Loading branch information
jooola authored Oct 9, 2023
1 parent a4f4a78 commit 1efd919
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ $ export MOLECULE_NO_LOG=False # not so verbose, helpful
$ export MOLECULE_DEBUG=True # very verbose, last ditch effort
```

You may also define a custom resource namespace by exposing the following
environment variables, for example in CI workflows:

```bash
$ export RESOURCE_NAMESPACE=e121dc64ff615ccdfac71bb5c00296b9 # Ensure the value length is <= 32
```

## Development

### Testing
Expand Down
2 changes: 1 addition & 1 deletion molecule_hetznercloud/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
resource_namespace: "{{ molecule_scenario_directory | md5 }}"
resource_namespace: "{{ lookup('ansible.builtin.env', 'RESOURCE_NAMESPACE') | default(molecule_scenario_directory | md5, true) }}"

ssh_port: 22
ssh_user: root
Expand Down
2 changes: 1 addition & 1 deletion molecule_hetznercloud/playbooks/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
resource_namespace: "{{ molecule_scenario_directory | md5 }}"
resource_namespace: "{{ lookup('ansible.builtin.env', 'RESOURCE_NAMESPACE') | default(molecule_scenario_directory | md5, true) }}"
tasks:
- name: Populate the instance config
ansible.builtin.set_fact:
Expand Down

0 comments on commit 1efd919

Please sign in to comment.