-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/sssd-sshd-compute-init
- Loading branch information
Showing
7 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
environments/skeleton/{{cookiecutter.environment}}/tofu/baremetal-node-list.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
""" opentofu external data program to list baremetal nodes | ||
Example usage: | ||
data "external" "example" { | ||
program = [this_file] | ||
} | ||
The external data resource's result attribute then contains a mapping of | ||
Ironic node names to their UUIDs. | ||
An empty list is returned if: | ||
- There are no baremetal nodes | ||
- The listing fails for any reason, e.g. | ||
- there is no baremetal service | ||
- admin credentials are required and are not provided | ||
""" | ||
|
||
import openstack | ||
import json | ||
|
||
nodes = [] | ||
proxy = None | ||
output = {} | ||
conn = openstack.connection.from_config() | ||
try: | ||
proxy = getattr(conn, 'baremetal', None) | ||
except Exception: | ||
pass | ||
if proxy is not None: | ||
nodes = proxy.nodes() | ||
for node in nodes: | ||
output[node.name] = node.id | ||
print(json.dumps(output)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
environments/skeleton/{{cookiecutter.environment}}/tofu/data.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
data "external" "inventory_secrets" { | ||
program = ["${path.module}/read-inventory-secrets.py"] | ||
|
||
query = { | ||
path = var.inventory_secrets_path == "" ? "${path.module}/../inventory/group_vars/all/secrets.yml" : var.inventory_secrets_path | ||
} | ||
} | ||
|
||
data "external" "baremetal_nodes" { | ||
# returns an empty map if cannot list baremetal nodes | ||
program = ["${path.module}/baremetal-node-list.py"] | ||
query = {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters