many changes

This commit is contained in:
hybris 2019-08-08 21:20:54 +02:00
parent d4cb32b9c3
commit dccf8ca00e
22 changed files with 297 additions and 133 deletions

View file

@ -1,24 +1,27 @@
---
- name: set terraform state directory
set_fact:
terraform_state_dir: "/home/{{ ansible_ssh_user }}/terraform/"
- name: remove files and directories
file:
path: "/home/{{ ansible_ssh_user }}/terraform/"
path: "{{ terraform_state_dir }}"
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 }}"
dest: "{{ terraform_state_dir }}{{ source_cloud_image_name }}"
remote_src: yes
- name: create vm definitions
template:
src: "cloud-init.tf.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.tf"
src: "terraform-libvirt-domain.tf.j2"
dest: "{{ terraform_state_dir }}{{ item.hostname }}.tf"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
with_items: "{{ kubernetes }}"
@ -26,7 +29,7 @@
- name: create cloud-init config
template:
src: "cloud-init.cfg.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.cloud_init.cfg"
dest: "{{ terraform_state_dir }}{{ item.hostname }}.cloud_init.cfg"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
with_items: "{{ kubernetes }}"
@ -34,7 +37,7 @@
- name: create cloud-init network config
template:
src: "cloud-init-network.cfg.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.cloud_init_network.cfg"
dest: "{{ terraform_state_dir }}{{ item.hostname }}.cloud_init_network.cfg"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
with_items: "{{ kubernetes }}"
@ -42,16 +45,18 @@
- name: create libvirt_provider config
template:
src: "libvirt_provider.tf.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/libvirt_provider.tf"
dest: "{{ terraform_state_dir }}libvirt_provider.tf"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
with_items:
- "{{ terraform_state_dir }}"
- name: initialize terraform
shell: terraform init
args:
chdir: /home/{{ ansible_ssh_user }}/terraform/
chdir: "{{ terraform_state_dir }}"
- name: terraform deploy
terraform:
project_path: /home/{{ ansible_ssh_user }}/terraform
state: present
# - name: terraform deploy
# terraform:
# project_path: /home/{{ ansible_ssh_user }}/terraform
# state: present