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

Externalize ansible variables #163

Merged
merged 6 commits into from
Jul 28, 2023
Merged
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
1 change: 1 addition & 0 deletions e2e/provision/.ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ warn_list:
- yaml
skip_list:
- experimental
- var-naming
exclude_paths:
- roles/deploy_mk8s/
mock_modules:
Expand Down
2 changes: 0 additions & 2 deletions e2e/provision/hosts.ini

This file was deleted.

4 changes: 2 additions & 2 deletions e2e/provision/install_sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ if [ "${DEPLOYMENT_TYPE:-r1}" == "one-summit" ]; then
else
# Management cluster creation
if [[ ${DEBUG:-false} != "true" ]]; then
ansible-playbook -i ./nephio.yaml playbooks/cluster.yml
ansible-playbook -i 127.0.0.1, playbooks/cluster.yml
else
ansible-playbook -vvv -i ./nephio.yaml playbooks/cluster.yml
ansible-playbook -vvv -i 127.0.0.1, playbooks/cluster.yml
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion e2e/provision/playbooks/cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##############################################################################

- name: Bootstrap Management cluster
hosts: vm
hosts: all
vars:
container_engine: docker
clab:
Expand Down
52 changes: 33 additions & 19 deletions e2e/provision/playbooks/library/kpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
type: str
output:
description:
- If specified, the output resources are written to provided location, if not specified, resources are modified in-place.
- If specified, the output resources are written to provided
location, if not specified, resources are modified in-place.
required: false
type: str
results_dir:
Expand All @@ -119,7 +120,8 @@
type: str
force:
description:
- Forces the inventory values to be updated, even if they are already set.
- Forces the inventory values to be updated, even if they are
already set.
required: false
type: bool
inventory_id:
Expand All @@ -129,12 +131,14 @@
type: str
name:
description:
- The name for the ResourceGroup resource that contains the inventory for the package.
- The name for the ResourceGroup resource that contains the
inventory for the package.
required: false
type: str
namespace:
description:
- The namespace for the ResourceGroup resource that contains the inventory for the package.
- The namespace for the ResourceGroup resource that contains the
inventory for the package.
required: false
type: str
rg_file:
Expand All @@ -144,7 +148,9 @@
type: str
dry_run:
description:
- It true, kpt will validate the resources in the package and print which resources will be applied and which resources will be pruned, but no resources will be changed.
- It true, kpt will validate the resources in the package and print
which resources will be applied and which resources will be
pruned, but no resources will be changed.
required: false
type: bool
field_manager:
Expand All @@ -155,17 +161,20 @@
default: kubectl
force_conflicts:
description:
- Force overwrite of field conflicts during apply due to different field managers.
- Force overwrite of field conflicts during apply due to different
field managers.
required: false
type: bool
install_resource_group:
description:
- Install the ResourceGroup CRD into the cluster if it isn't already available.
- Install the ResourceGroup CRD into the cluster if it isn't already
available.
required: false
type: bool
inventory_policy:
description:
- Determines how to handle overlaps between the package being currently applied and existing resources in the cluster.
- Determines how to handle overlaps between the package being
currently applied and existing resources in the cluster.
required: false
type: str
choices:
Expand All @@ -182,12 +191,14 @@
- Orphan
prune_timeout:
description:
- The threshold for how long to wait for all pruned resources to be deleted before giving up.
- The threshold for how long to wait for all pruned resources to be
deleted before giving up.
required: false
type: str
reconcile_timeout:
description:
- The threshold for how long to wait for all resources to reconcile before giving up.
- The threshold for how long to wait for all resources to reconcile
before giving up.
required: false
type: str
server_side:
Expand All @@ -197,7 +208,8 @@
type: bool
show_status_events:
description:
- The output will include the details on the reconciliation status for all resources.
- The output will include the details on the reconciliation status
for all resources.
required: false
type: bool
context:
Expand Down Expand Up @@ -253,15 +265,17 @@
returned: changed
type: str
stdout_lines:
description: A list of strings, each containing one item per line from the original output.
description: A list of strings, each containing one item per line from the
original output.
returned: changed
type: str
stderr:
description: Output on stderr
returned: changed
type: str
stderr_lines:
description: A list of strings, each containing one item per line from the original error.
description: A list of strings, each containing one item per line from the
original error.
returned: changed
type: str
""" # noqa: F841
Expand All @@ -288,7 +302,7 @@ def _run(self, cmd, changed=True):
self._module.exit_json(**result)

# Show resources in the current directory.
def pkg_tree(self, directory, **kargs):
def pkg_tree(self, directory, **kwargs):
cmd = [self._kpt_cmd_path, "pkg", "tree"]
if directory:
cmd.append(directory)
Expand All @@ -303,7 +317,7 @@ def pkg_get(
version,
strategy,
for_deployment,
**kargs
**kwargs
):
cmd = [self._kpt_cmd_path, "pkg", "get"]
cmd.append(
Expand Down Expand Up @@ -337,7 +351,7 @@ def pkg_get(

# Show differences between a local package and upstream.
def pkg_diff(
self, pkg_path, version, diff_type, diff_tool, diff_tool_opts, **kargs
self, pkg_path, version, diff_type, diff_tool, diff_tool_opts, **kwargs
):
cmd = [self._kpt_cmd_path, "pkg", "diff"]
if pkg_path:
Expand All @@ -358,7 +372,7 @@ def pkg_diff(

# Render a package.
def fn_render(
self, pkg_path, allow_exec, image_pull_policy, output, results_dir, **kargs
self, pkg_path, allow_exec, image_pull_policy, output, results_dir, **kwargs
):
cmd = [self._kpt_cmd_path, "fn", "render"]
if pkg_path:
Expand All @@ -375,7 +389,7 @@ def fn_render(

# Initialize a package with the information needed for inventory tracking.
def live_init(
self, pkg_path, force, inventory_id, name, namespace, rg_file, context, **kargs
self, pkg_path, force, inventory_id, name, namespace, rg_file, context, **kwargs
):
cmd = [self._kpt_cmd_path, "live", "init"]
if pkg_path:
Expand Down Expand Up @@ -410,7 +424,7 @@ def live_apply(
server_side,
show_status_events,
context,
**kargs
**kwargs
):
cmd = [self._kpt_cmd_path, "live", "apply"]
if pkg_path:
Expand Down
74 changes: 49 additions & 25 deletions e2e/provision/playbooks/roles/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,39 @@ This role installs and configures the tool set required to deploy a Nephio Manag

Available variables are listed below, along with default values (see defaults/main.yml):

| Variable | Required | Default | Choices | Comments |
|--------------------------|----------|------------|---------------------------|---------------------------------------------------------------|
| host_min_vcpu | no | 8 | | Minimum vCPUs required |
| host_min_cpu_ram | no | 16 | | Minimum RAM required (GB) |
| host_min_root_disk_space | no | 50 | | Minimum disk space required (GB) |
| container_engine | no | docker | docker | Container engine utilized for the management cluster creation |
| kubernetes_version | no | v1.27.1 | | Kubernetes version used for the management cluster |
| gitea_postgres_password | no | c2VjcmV0 | | `postgres-password` secret value for gitea database service |
| gitea_db_password | no | c2VjcmV0 | | `password` secret value for gitea service |
| gitea_username | no | nephio | | Gitea admin user name |
| gitea_password | no | secret | | Gitea admin password |
| gtp5g_dest | no | /opt/gtp5g | | Destination path for GTP5G source code |
| gtp5g_version | no | v0.6.8 | | GTP5G source code version |
| gtp5g_tarball_url | no | | | GTP5G tarball URI |
| Variable | Required | Default | Choices | Comments |
|---------------------------------|----------|---------------|---------------------------|-----------------------------------------------------------------------------------|
| host_min_vcpu | no | 8 | | Minimum vCPUs required |
| host_min_cpu_ram | no | 16 | | Minimum RAM required (GB) |
| host_min_root_disk_space | no | 50 | | Minimum disk space required (GB) |
| container_engine | no | docker | docker | Container engine utilized for the management cluster creation |
| gtp5g_dest | no | /opt/gtp5g | | Destination path for GTP5G source code |
| gtp5g_version | no | v0.6.8 | | GTP5G source code version |
| gtp5g_tarball_url | no | | | GTP5G tarball URI |
| k8s.context | no | kind-kind | | Kubernetes context to create gitea resources |
| k8s.version | no | v1.27.1 | | Kubernetes version used for the management cluster |
| kind.enabled | no | true | true, false | Enable/Disable Kubernetes Cluster creation |
| nephio_pkg_version | no | v1.0.1-beta.1 | | Default version for all kpt packages |
| gitea.enabled | no | true | true, false | Enable/Disable gitea services |
| gitea.k8s.namespace | no | gitea | | Kubernetes namespace for gitea resources |
| gitea.k8s.postgres_password | no | c2VjcmV0 | | `postgres-password` secret value for gitea database service |
| gitea.k8s.db_password | no | c2VjcmV0 | | `password` secret value for gitea service |
| gitea.k8s.username | no | nephio | | Gitea admin user name |
| gitea.k8s.password | no | secret | | Gitea admin password |
| gitea.k8s.namespaces | no | | | List of Kubernetes namespaces to watch for gitea deployment rersources |
| gitea.kpt.packages | no | | | List of gitea kpt packages |
| resource_backend.enabled | no | true | true, false | Enable/Disable resource-backend services |
| resource_backend.k8s.namespaces | no | | | List of Kubernetes namespaces to watch for resource-backend deployment rersources |
| resource_backend.kpt.packages | no | | | List of resource-backend kpt packages |
| cert_manager.enabled | no | true | true, false | Enable/Disable cert-manager services |
| cert_manager.k8s.namespaces | no | | | List of Kubernetes namespaces to watch for cert-manager deployment rersources |
| cert_manager.kpt.packages | no | | | List of cert-manager kpt packages |
| cluster_api.enabled | no | true | true, false | Enable/Disable cluster-api services |
| cluster_api.k8s.namespaces | no | | | List of Kubernetes namespaces to watch for cluster-api deployment rersources |
| cluster_api.kpt.packages | no | | | List of cluster-api kpt packages |
| metallb.enabled | no | true | true, false | Enable/Disable MetalLB services |
| metallb.k8s.namespaces | no | | | List of Kubernetes namespaces to watch for MetalLB deployment rersources |
| metallb.kpt.packages | no | | | List of MetalLB kpt packages |

## Dependencies

Expand Down Expand Up @@ -58,11 +77,14 @@ The `install` Ansible role depends on the outcome generated by this role.
src: https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.38/kpt_linux_amd64-1.0.0-beta.38.tar.gz
dest: /usr/local/bin/
creates: /usr/local/bin/kpt
roles:
- andrewrothstein.kind
- andrewrothstein.kubectl
- role: andrewrothstein.docker_engine
- name: Install KinD command-line
ansible.builtin.include_role:
name: andrewrothstein.kind
- name: Install Docker Engine
become: true
ansible.builtin.include_role:
name: andrewrothstein.docker_engine
roles:
- bootstrap
```

Expand All @@ -87,18 +109,20 @@ flowchart TD
M -- false --> P
O -->|Set Kernel Parameters| P(Set kernel parameters)
P --> Q(Force all notified handlers to run at this point)
Q --> R(Get k8s clusters)
Q -->|Create Management KinD Cluster| R(Get k8s clusters)
R --> S{not 'kind' in bootstrap_kind_get_cluster.stdout?}
S -- true --> T(Create management cluster)
T --> U(Create .kube directory)
S -- false --> U
U --> V(Copy root kubeconfig file)
V --> W(Wait for Kind Nodes to become ready)
W --> Y(Create gitea namespace)
W -->|Create Gitea K8s resources| Y(Create gitea namespace)
Y --> Z(Create gitea postgresql user password)
Z --> AA(Init job ids array)
AA --> AB(Deploy base packages)
AB --> AC(Wait for packages to be applied)
AC --> |Wait for deployments| AD(Get deployment resources)
AD --> AF(Wait for deployments)
Z -->|Apply kpt packages| AA(Init job ids array)
AA --> AB(Create list of packages)
AB --> AC(Deploy base packages)
AC --> AD(Wait for packages to be applied)
AD --> AF(Create list of namespaces)
AF --> |Wait for deployments| AE(Get deployment resources)
AE --> AG(Wait for deployments)
```
Loading