58 lines
1.7 KiB
YAML
58 lines
1.7 KiB
YAML
---
|
|
|
|
- name: remove files and directories
|
|
file:
|
|
path: "/home/{{ ansible_ssh_user }}/terraform/"
|
|
state: "{{ item }}"
|
|
with_items:
|
|
- absent
|
|
- directory
|
|
|
|
# TODO: make it actually download the image, lol (module:uri)
|
|
- name: "download qcow2 cloud image"
|
|
copy:
|
|
src: "/home/{{ ansible_ssh_user }}/images/{{ source_cloud_image_name }}"
|
|
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ source_cloud_image_name }}"
|
|
remote_src: yes
|
|
|
|
- name: create vm definitions
|
|
template:
|
|
src: "../files/cloud-init.tf.j2"
|
|
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.tf"
|
|
owner: "{{ ansible_ssh_user }}"
|
|
group: "{{ ansible_ssh_user }}"
|
|
with_items: "{{ kubernetes }}"
|
|
|
|
- name: create cloud-init config
|
|
template:
|
|
src: "../files/cloud-init.cfg.j2"
|
|
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.cloud_init.cfg"
|
|
owner: "{{ ansible_ssh_user }}"
|
|
group: "{{ ansible_ssh_user }}"
|
|
with_items: "{{ kubernetes }}"
|
|
|
|
- name: create cloud-init network config
|
|
template:
|
|
src: "../files/cloud-init-network.cfg.j2"
|
|
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.cloud_init_network.cfg"
|
|
owner: "{{ ansible_ssh_user }}"
|
|
group: "{{ ansible_ssh_user }}"
|
|
with_items: "{{ kubernetes }}"
|
|
|
|
- name: create libvirt_provider config
|
|
template:
|
|
src: "../files/libvirt_provider.tf.j2"
|
|
dest: "/home/{{ ansible_ssh_user }}/terraform/libvirt_provider.tf"
|
|
owner: "{{ ansible_ssh_user }}"
|
|
group: "{{ ansible_ssh_user }}"
|
|
|
|
- name: initialize terraform
|
|
shell: terraform init
|
|
args:
|
|
chdir: /home/{{ ansible_ssh_user }}/terraform/
|
|
|
|
- name: terraform deploy
|
|
terraform:
|
|
project_path: /home/{{ ansible_ssh_user }}/terraform
|
|
state: present
|