GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(module-api): introduce module_role_path for use within modules · getstackhead/stackhead@f82a8fd

This repository was archived by the owner on Feb 26, 2024. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Documentation/stackhead-modules/development
    • specification.md
  • ansible
    • README.md
    • plugins/action
      • module_load_config.py
    • roles/stackhead_module_api/tasks_internal
      • execute-module-step.yml
    • test/units/plugins/action
      • module_load_config.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Documentation/stackhead-modules/development/specification.md‎

Copy file name to clipboardExpand all lines: Documentation/stackhead-modules/development/specification.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Make sure the following files exist and the expected behaviour is implemented ac
3737
| `tasks/steps/deploy.yml` | The software is configured for the given project. | Project deployment |
3838
| `tasks/steps/destroy.yml` | The project configuration for the software is removed. Usually empty as resources created via Terraform are removed automatically. | Project destruction |
3939

40+
{% hint style="warning" %}
41+
Note that `role_path` will most likely not refer to the path to your role, but to a StackHead role.
42+
StackHead provides the path to your role as `module_role_path`, so you should use that preferably:
43+
`{{ module_role_path | default(role_path) }}`
44+
{% endhint %}
45+
4046
{% hint style="warning" %}
4147
Please make sure you use `include_tasks` instead of `import_tasks` in your steps and files included into your steps!
4248
{% endhint %}
Collapse file

‎ansible/README.md‎

Copy file name to clipboardExpand all lines: ansible/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ Due to the collision of the "ansible" python package and our local "ansible" fol
1515
we have to back one directory in order to run tests.
1616

1717
```
18-
(cd .. && python -m unittest stackhead/ansible/test/units/plugins/action/module_load_config.py)
18+
(cd .. && python -m unittest stackhead/ansible/test/units/**/**/*.py)
1919
```
Collapse file

‎ansible/plugins/action/module_load_config.py‎

Copy file name to clipboardExpand all lines: ansible/plugins/action/module_load_config.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def tf_populate_module_config(self, included_module_config, module_rolepath):
3939

4040
init_path = included_module_config['terraform']['provider']['init']
4141

42-
double_quotes = re.compile(r'^{{\s*role_path\s*}}(.*)$')
43-
init_path = double_quotes.sub(module_rolepath + "\\1", init_path)
42+
init_path = re.compile(r'^{{\s*role_path.*\s*}}(.*)$').sub(module_rolepath + "\\1", init_path)
43+
init_path = re.compile(r'^{{\s*module_role_path.*\s*}}(.*)$').sub(module_rolepath + "\\1", init_path)
4444

4545
included_module_config['terraform']['provider']['init'] = init_path
4646
return included_module_config
Collapse file

‎ansible/roles/stackhead_module_api/tasks_internal/execute-module-step.yml‎

Copy file name to clipboardExpand all lines: ansible/roles/stackhead_module_api/tasks_internal/execute-module-step.yml
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
vars:
77
module_config: "{{ loaded_config.config_varname }}"
88
- name: "{{ stackhead_action }} {{ module_group }} ({{ module_name }}) configuration"
9-
include_tasks: "{{ lookup('getstackhead.stackhead.role_path', module_name)}}/tasks/steps/{{ stackhead_action }}.yml"
9+
include_tasks: "{{ module_role_path }}/tasks/steps/{{ stackhead_action }}.yml"
10+
vars:
11+
module_role_path: "{{ lookup('getstackhead.stackhead.role_path', module_name) }}"
Collapse file

‎ansible/test/units/plugins/action/module_load_config.py‎

Copy file name to clipboardExpand all lines: ansible/test/units/plugins/action/module_load_config.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ def test_replacing_role_path_in_terraform_provider_init_path(self):
5555
{'foo': 'bar', 'terraform': {'provider': {'init': '{{role_path}}/test'}}}, '/some/path')
5656
self.assertEqual({'foo': 'bar', 'terraform': {'provider': {'init': '/some/path/test'}}}, result)
5757

58+
# module_role_path variable in init
59+
result = subject.tf_populate_module_config(
60+
{'foo': 'bar', 'terraform': {'provider': {'init': '{{ module_role_path }}/test'}}}, '/some/path')
61+
self.assertEqual({'foo': 'bar', 'terraform': {'provider': {'init': '/some/path/test'}}}, result)
62+
63+
# module_role_path variable in init
64+
result = subject.tf_populate_module_config(
65+
{'foo': 'bar', 'terraform': {'provider': {'init': '{{module_role_path}}/test'}}}, '/some/path')
66+
self.assertEqual({'foo': 'bar', 'terraform': {'provider': {'init': '/some/path/test'}}}, result)
67+
68+
# module_role_path|default(role_path) variable in init
69+
result = subject.tf_populate_module_config(
70+
{'foo': 'bar', 'terraform': {'provider': {'init': '{{ module_role_path | default(role_path) }}/test'}}}, '/some/path')
71+
self.assertEqual({'foo': 'bar', 'terraform': {'provider': {'init': '/some/path/test'}}}, result)
72+
73+
# module_role_path|default(role_path) variable in init
74+
result = subject.tf_populate_module_config(
75+
{'foo': 'bar', 'terraform': {'provider': {'init': '{{module_role_path|default(role_path)}}/test'}}}, '/some/path')
76+
self.assertEqual({'foo': 'bar', 'terraform': {'provider': {'init': '/some/path/test'}}}, result)
77+
5878
def test_get_role_path_of_regular_role(self):
5979
task = MagicMock(Task)
6080
task.async_val = False

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.