Skip to content

Commit

Permalink
Allow serving additional files along with ztp.sh. (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Jul 26, 2024
1 parent 6319bc7 commit ca47bba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions partition/roles/ztp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Configures a server for providing zero-touch-provisioning scripts for switches.
| 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. |
4 changes: 4 additions & 0 deletions partition/roles/ztp/defaults/main/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ ztp_authorized_keys:
ztp_admin_user: admin

ztp_port: 8080

ztp_additional_files: []
# - name: foo.sh
# data: echo
10 changes: 10 additions & 0 deletions partition/roles/ztp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- ztp_nginx_image_name is defined
- ztp_nginx_image_tag is defined
- ztp_authorized_keys is not none
- "'ztp.sh' not in ztp_additional_files | map(attribute='name')"

- name: create ztp config directory
file:
Expand All @@ -22,6 +23,15 @@
dest: "{{ ztp_host_dir_path }}/config/ztp.sh"
mode: 0644

- name: copy additional contents
copy:
dest: "{{ ztp_host_dir_path }}/config/{{ item.name }}"
content: "{{ item.data }}"
mode: 0644
loop: "{{ ztp_additional_files }}"
loop_control:
label: "{{ item.name }}"

- name: deploy server for serving ztp.sh
include_role:
name: ansible-common/roles/systemd-docker-service
Expand Down

0 comments on commit ca47bba

Please sign in to comment.