# Copyright 2019 The Kubernetes Authors.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- include_tasks: vmware-photon.yml
  when: ansible_os_family == "VMware Photon OS"

- include_tasks: vmware-ubuntu.yml
  when: ansible_os_family == "Debian"

- include_tasks: vmware-redhat.yml
  when: ansible_os_family == "RedHat"

- name: Create provider vmtools config drop-in file
  copy:
    src: files/etc/vmware-tools/tools.conf
    dest: /etc/vmware-tools/tools.conf
    owner: root
    group: root
    mode: 0644
  when: ansible_os_family != "Flatcar"

- name: Create service to modify cloud-init config
  copy:
    src: files/etc/systemd/system/modify-cloud-init-cfg.service
    dest: /etc/systemd/system/modify-cloud-init-cfg.service
    owner: root
    group: root
    mode: 0644
  when: ansible_os_family != "Flatcar"

- name: Copy cloud-init modification script
  copy:
    src: files/usr/local/bin/modify-cloud-init-cfg.sh
    dest: /usr/local/bin/modify-cloud-init-cfg.sh
    owner: root
    group: root
    mode: 0755
  when: ansible_os_family != "Flatcar"

- name: Enable modify-cloud-init-cfg.service
  systemd:
    name: modify-cloud-init-cfg.service
    daemon_reload: yes
    enabled: True
    state: stopped
  when: ansible_os_family != "Flatcar"