Skip to content

Commit

Permalink
ztp provisioning script as a template
Browse files Browse the repository at this point in the history
  • Loading branch information
iljarotar committed Dec 12, 2024
1 parent 3384bc2 commit eb95178
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
21 changes: 11 additions & 10 deletions partition/roles/ztp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ The result of this is unpredictable and, in the worst case, the switch might rea

## Variables

| Name | Mandatory | Description |
| -------------------- | --------- | ----------------------------------------------------------- |
| ztp_nginx_image_name | yes | the docker image to use to serve ztp scripts. |
| ztp_nginx_image_tag | yes | the tag of the docker image to use to serve ztp scripts. |
| ztp_host_dir_path | | the path to serve ztp scripts from. |
| ztp_listen_address | | the address used to serve ztp requests |
| ztp_port | | the port to serve ztp scripts on. |
| ztp_authorized_keys | yes | the authorized keys that should be installed by ztp. |
| ztp_admin_user | | the user for which the authorized keys will be provisioned. |
| ztp_additional_files | | puts additional files into serve directory. |
| Name | Mandatory | Description |
| ----------------------- | --------- | ---------------------------------------------------------------------------------------------- |
| ztp_nginx_image_name | yes | the docker image to use to serve ztp scripts. |
| ztp_nginx_image_tag | yes | the tag of the docker image to use to serve ztp scripts. |
| ztp_host_dir_path | | the path to serve ztp scripts from. |
| ztp_listen_address | | the address used to serve ztp requests |
| ztp_port | | the port to serve ztp scripts on. |
| ztp_authorized_keys | yes | the authorized keys that should be installed by ztp. |
| ztp_admin_user | | the user for which the authorized keys will be provisioned. |
| ztp_additional_files | | puts additional files into serve directory. |
| ztp_provisioning_script | | jinja template for optional ztp-provisioning-script.sh to be executed at the end of `ztp.json` |
7 changes: 7 additions & 0 deletions partition/roles/ztp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
- ztp.json.j2
- ztp.sh.j2

- name: render ztp-provisioning-script
template:
content: "{{ ztp_provisioning_script }}"
dest: "{{ ztp_host_dir_path }}/config/ztp-provisioning-script.sh"
mode: 0644
when: ztp_provisioning_script is defined

- name: copy frr.conf
copy:
dest: "{{ ztp_host_dir_path }}/config/frr.conf"
Expand Down
2 changes: 1 addition & 1 deletion partition/roles/ztp/templates/ztp.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"clear-config": true
},
{% if ztp_additional_files | selectattr('name', 'equalto', 'ztp-provisioning-script.sh') %}
{% if ztp_provisioning_script %}
"05-provisioning-script": {
"plugin": {
"url": "http://{{ ztp_listen_address }}:{{ ztp_port }}/ztp-provisioning-script.sh"
Expand Down

0 comments on commit eb95178

Please sign in to comment.