many changes
This commit is contained in:
parent
d4cb32b9c3
commit
dccf8ca00e
22 changed files with 297 additions and 133 deletions
|
@ -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
|
||||
|
|
|
@ -8,10 +8,11 @@ users:
|
|||
write_files:
|
||||
- content: |
|
||||
#!/bin/bash
|
||||
# inet6_addr=$(ip a s | grep "inet6 2001:470:6d:22c:" | awk '{print substr($2,0)}')
|
||||
sudo hostnamectl set-hostname {{ item.hostname }}
|
||||
#sudo ip -6 addr add {{ item.ipv6 }}/64 dev eth0
|
||||
sudo hostnamectl set-hostname {{ item.hostname_full }}
|
||||
sudo chown -R {{ ansible_ssh_user }}:{{ ansible_ssh_user }} /home/{{ ansible_ssh_user }}
|
||||
#yum install qemu-guest-agent
|
||||
#systemctl start qemu-guest-agent
|
||||
#systemctl enable qemu-guest-agent
|
||||
path: /home/{{ ansible_ssh_user }}/cloud-init.sh
|
||||
owner: {{ ansible_ssh_user }}:{{ ansible_ssh_user }}
|
||||
permissions: '0744'
|
||||
|
|
|
@ -46,4 +46,3 @@ data "template_file" "user-data-{{ item.hostname }}" {
|
|||
data "template_file" "network-config-{{ item.hostname }}" {
|
||||
template = "${file("${path.module}/{{ item.hostname }}.cloud_init_network.cfg")}"
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue