From 47c6cf891f3f5f30a7753cc03aff59d84454e71a Mon Sep 17 00:00:00 2001 From: guppy Date: Thu, 1 Jun 2023 15:56:25 +0200 Subject: [PATCH] Add hostpath roles --- hostpath.yaml | 5 +++++ roles/hostpath/files/index.html | 10 ++++++++++ roles/hostpath/tasks/main.yaml | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 hostpath.yaml create mode 100644 roles/hostpath/files/index.html create mode 100644 roles/hostpath/tasks/main.yaml diff --git a/hostpath.yaml b/hostpath.yaml new file mode 100644 index 0000000..7df80de --- /dev/null +++ b/hostpath.yaml @@ -0,0 +1,5 @@ +--- +- hosts: worker-node + name: "HostPath" + roles: + - role: hostpath diff --git a/roles/hostpath/files/index.html b/roles/hostpath/files/index.html new file mode 100644 index 0000000..122eac8 --- /dev/null +++ b/roles/hostpath/files/index.html @@ -0,0 +1,10 @@ + + + + +

This file is on k8s-worker-node2 at /data

+ +

Hello World!

+ + + diff --git a/roles/hostpath/tasks/main.yaml b/roles/hostpath/tasks/main.yaml new file mode 100644 index 0000000..292149c --- /dev/null +++ b/roles/hostpath/tasks/main.yaml @@ -0,0 +1,13 @@ +- name: create data dir on K8s-worker-node2 + become: yes + file: + path: /data + state: directory + when: "'K8s-worker-node2' in ansible_facts.hostname" + +- name: copy file on K8s-worker-node2 + become: yes + copy: + src: index.html + dest: /data/ + when: "'K8s-worker-node2' in ansible_facts.hostname"