make everything more configurable
This commit is contained in:
parent
ad8e3cc155
commit
0482b34923
@ -5,31 +5,55 @@
|
|||||||
##########################################
|
##########################################
|
||||||
###### DEFINE YOUR MACHINES HERE
|
###### DEFINE YOUR MACHINES HERE
|
||||||
vars:
|
vars:
|
||||||
|
# libvirt host vars
|
||||||
|
libvirt_host: [2001:470:6d:22c:1::1]
|
||||||
|
libvirt_storage_pool: kubernetes
|
||||||
|
libvirt_network_bridge: home-lan
|
||||||
|
|
||||||
|
# ansible user vars
|
||||||
|
# python -c 'import crypt; print crypt.crypt("This is my Password", "$1$SomeSalt$")'
|
||||||
|
remote_user_pass: $1$tG6Uv4$BPCIRF6RFuLrJ.lQO1GB8.
|
||||||
|
remote_user_ssh_pubkey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDXh0iMMtbTEhRSgIbgCunAuE+Q1iKycRVRBYWDCQ45xE8nHsg7K98fdv6LqQwkTqlojEHKp2/TPawk8V6w3MTgOHXi/WO9FyvhMjUcfdxTvny1z3Pj1j0NglKjyQ3t30snwOBYJiC2qDDtvRYNJs+Re/aSdVbygOHMf0UqCyP8DL7Tcj5sNPgnleEC7jE+YNbyDJo2KtNFXy3+AMbwa742D5Ygi5FqaBO090gVQfb3hbnZLw9CNSK7vjo7k5hJo8d1kcPDth1Vo12IDejL8Al3ArfGSy5IqYXs8Stj4YVRW+78AOpQZiInCaFybqjsGG+5tezrXHrxhjJPHuSCuXk9vxkcUk7aC5eSDqoCP7RTB+iQCPJ1ZvkVbaebExZGgHpD9t2Xo2bd/3BRagIxPTzKo9q4+qCCClhWR4iUSOr/YKAZBFDdoVWg2IMqbUHzvHX7TE7I8hbAdg6CpgwBoJm8OWmfjkDU6aYnF8z9l36VV7xjvvuYbOrhpCJ9LGFSfmG3wswo8OH4XyRSHd3y7qrSYIGujtymrzozXo2MrMU3Rj2bW5MIEZSxleIVje4PHWOfZwwn3hwvqM/nyknzfNwPCidTsP3Q2FwfBtZYo1cIXH41bzjs4Bxb8+KJqwTcerzB1pT4qsoPnoYW0fnZE7NHVNhfNx53LdctclFerHTLMw== hybris@sparks
|
||||||
|
|
||||||
|
## does this make sense??
|
||||||
|
source_cloud_image_name: CentOS-7-x86_64-GenericCloud.qcow2
|
||||||
|
source_cloud_image_url: https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1503.qcow2
|
||||||
|
|
||||||
kubernetes:
|
kubernetes:
|
||||||
- hostname: k8s-master
|
- hostname: k8s-master
|
||||||
ipv6: 2001:470:6d:22c:42::1
|
ipv6: 2001:470:6d:22c:42::1
|
||||||
mac_address: 52:54:00:b2:52:86
|
mac_address: 52:54:00:b2:52:86
|
||||||
|
memory: 5072
|
||||||
|
vcpu: 2
|
||||||
- hostname: k8s-node-1
|
- hostname: k8s-node-1
|
||||||
ipv6: 2001:470:6d:22c:42::10
|
ipv6: 2001:470:6d:22c:42::10
|
||||||
mac_address: 52:54:00:52:b2:b2
|
mac_address: 52:54:00:52:b2:b2
|
||||||
|
memory: 5072
|
||||||
|
vcpu: 2
|
||||||
- hostname: k8s-node-2
|
- hostname: k8s-node-2
|
||||||
ipv6: 2001:470:6d:22c:42::20
|
ipv6: 2001:470:6d:22c:42::20
|
||||||
mac_address: 52:54:00:52:2f:86
|
mac_address: 52:54:00:52:2f:86
|
||||||
|
memory: 5072
|
||||||
|
vcpu: 2
|
||||||
- hostname: k8s-node-3
|
- hostname: k8s-node-3
|
||||||
ipv6: 2001:470:6d:22c:42::30
|
ipv6: 2001:470:6d:22c:42::30
|
||||||
mac_address: 52:54:00:52:2f:b2
|
mac_address: 52:54:00:52:2f:b2
|
||||||
|
memory: 5072
|
||||||
|
vcpu: 2
|
||||||
- hostname: k8s-node-4
|
- hostname: k8s-node-4
|
||||||
ipv6: 2001:470:6d:22c:42::40
|
ipv6: 2001:470:6d:22c:42::40
|
||||||
mac_address: 52:54:00:b2:2f:86
|
mac_address: 52:54:00:b2:2f:86
|
||||||
|
memory: 5072
|
||||||
|
vcpu: 2
|
||||||
######
|
######
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
# - name: download qcow2 cloud image
|
- name: download qcow2 cloud image
|
||||||
# uri:
|
uri:
|
||||||
# url:
|
url: {{ source_cloud_image_url }}
|
||||||
# dest:
|
dest: /home/{{ remote_user }}/terraform/{{ source_cloud_image_name }}
|
||||||
|
|
||||||
- name: create vm definitions
|
- name: create vm definitions
|
||||||
template:
|
template:
|
||||||
@ -71,3 +95,4 @@
|
|||||||
shell: terraform apply "cloud-init-plan"
|
shell: terraform apply "cloud-init-plan"
|
||||||
args:
|
args:
|
||||||
chdir: /home/{{ remote_user }}/terraform
|
chdir: /home/{{ remote_user }}/terraform
|
||||||
|
[]
|
@ -3,6 +3,10 @@
|
|||||||
remote_user: hybris
|
remote_user: hybris
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
|
vars:
|
||||||
|
# rename this to something with sense
|
||||||
|
network_default_gw: 2001:470:6d:22c::1
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- dns
|
- dns
|
||||||
- proxy
|
- proxy
|
||||||
|
@ -1,4 +1,22 @@
|
|||||||
---
|
---
|
||||||
|
#######################
|
||||||
|
#### NETWORK TASKS ####
|
||||||
|
#######################
|
||||||
|
|
||||||
|
- name: set static ipv6 for hosts
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/sysconfig/network-scripts/ifcfg-eth0
|
||||||
|
line: {{ item.line }}
|
||||||
|
regexp: {{ item.regexp }}
|
||||||
|
with_items:
|
||||||
|
- { regexp: "^IPV6INIT=", line: "IPV6INIT=yes" }
|
||||||
|
- { regexp: "^IPV6AUTOCONF=", line: "IPV6AUTOCONF=no" }
|
||||||
|
- { regexp: "^IPV6ADDR=", line: "IPV6ADDR={{ host_ipv6 }}"}
|
||||||
|
- { regexp: "^IPV6_DEFAULTGW=", line: "IPV6_DEFAULTGW={{ network_default_gw }}"}
|
||||||
|
|
||||||
|
- name: reboot
|
||||||
|
reboot:
|
||||||
|
|
||||||
########################
|
########################
|
||||||
#### FIREWALL TASKS ####
|
#### FIREWALL TASKS ####
|
||||||
########################
|
########################
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
users:
|
users:
|
||||||
- name: {{ remote_user }}
|
- name: {{ remote_user }}
|
||||||
lock-passwd: false
|
lock-passwd: false
|
||||||
passwd: $1$tG6Uv4$BPCIRF6RFuLrJ.lQO1GB8.
|
passwd: {{ remote_user_pass }}
|
||||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||||
ssh_authorized_keys:
|
ssh_authorized_keys:
|
||||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDXh0iMMtbTEhRSgIbgCunAuE+Q1iKycRVRBYWDCQ45xE8nHsg7K98fdv6LqQwkTqlojEHKp2/TPawk8V6w3MTgOHXi/WO9FyvhMjUcfdxTvny1z3Pj1j0NglKjyQ3t30snwOBYJiC2qDDtvRYNJs+Re/aSdVbygOHMf0UqCyP8DL7Tcj5sNPgnleEC7jE+YNbyDJo2KtNFXy3+AMbwa742D5Ygi5FqaBO090gVQfb3hbnZLw9CNSK7vjo7k5hJo8d1kcPDth1Vo12IDejL8Al3ArfGSy5IqYXs8Stj4YVRW+78AOpQZiInCaFybqjsGG+5tezrXHrxhjJPHuSCuXk9vxkcUk7aC5eSDqoCP7RTB+iQCPJ1ZvkVbaebExZGgHpD9t2Xo2bd/3BRagIxPTzKo9q4+qCCClhWR4iUSOr/YKAZBFDdoVWg2IMqbUHzvHX7TE7I8hbAdg6CpgwBoJm8OWmfjkDU6aYnF8z9l36VV7xjvvuYbOrhpCJ9LGFSfmG3wswo8OH4XyRSHd3y7qrSYIGujtymrzozXo2MrMU3Rj2bW5MIEZSxleIVje4PHWOfZwwn3hwvqM/nyknzfNwPCidTsP3Q2FwfBtZYo1cIXH41bzjs4Bxb8+KJqwTcerzB1pT4qsoPnoYW0fnZE7NHVNhfNx53LdctclFerHTLMw== hybris@sparks
|
- {{ remote_user_ssh_pubkey }}
|
||||||
write_files:
|
write_files:
|
||||||
- content: |
|
- content: |
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
resource "libvirt_cloudinit_disk" "cloud-init-{{ item.hostname }}" {
|
resource "libvirt_cloudinit_disk" "cloud-init-{{ item.hostname }}" {
|
||||||
name = "cloud-init-{{ item.hostname }}.iso"
|
name = "cloud-init-{{ item.hostname }}.iso"
|
||||||
pool = "kubernetes"
|
pool = "{{ libvirt_storage_pool }}"
|
||||||
user_data = "${data.template_file.user-data-{{ item.hostname }}.rendered}"
|
user_data = "${data.template_file.user-data-{{ item.hostname }}.rendered}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8,17 +8,17 @@ data "template_file" "user-data-{{ item.hostname }}" {
|
|||||||
template = "${file("${path.module}/{{ item.hostname }}.cloud_init.cfg")}"
|
template = "${file("${path.module}/{{ item.hostname }}.cloud_init.cfg")}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "libvirt_volume" "centos-7-generic-{{ item.hostname }}" {
|
resource "libvirt_volume" "{{ item.hostname }}" {
|
||||||
name = "centos-7-generic-{{ item.hostname }}"
|
name = "{{ item.hostname }}"
|
||||||
source = "CentOS-7-x86_64-GenericCloud.qcow2"
|
source = "{{ source_cloud_image_name }}"
|
||||||
pool = "kubernetes"
|
pool = "{{ libvirt_storage_pool }}"
|
||||||
format = "qcow2"
|
format = "qcow2"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "libvirt_domain" "domain-{{ item.hostname }}" {
|
resource "libvirt_domain" "domain-{{ item.hostname }}" {
|
||||||
name = "{{ item.hostname }}"
|
name = "{{ item.hostname }}"
|
||||||
memory = "1024"
|
memory = "{{ item.memory }}"
|
||||||
vcpu = 1
|
vcpu = "{{ item.vcpu }}"
|
||||||
|
|
||||||
cloudinit = "${libvirt_cloudinit_disk.cloud-init-{{ item.hostname }}.id}"
|
cloudinit = "${libvirt_cloudinit_disk.cloud-init-{{ item.hostname }}.id}"
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ resource "libvirt_domain" "domain-{{ item.hostname }}" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
bridge = "home-lan"
|
bridge = "{{ libvirt_network_bridge }}"
|
||||||
mac = "{{ item.mac_address }}"
|
mac = "{{ item.mac_address }}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ resource "libvirt_domain" "domain-{{ item.hostname }}" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disk {
|
disk {
|
||||||
volume_id = "${libvirt_volume.centos-7-generic-{{ item.hostname }}.id}"
|
volume_id = "${libvirt_volume.{{ item.hostname }}.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics {
|
graphics {
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
provider "libvirt" {
|
provider "libvirt" {
|
||||||
uri = "qemu+ssh://[2001:470:6d:22c:1::1]/system?socket=/var/run/libvirt/libvirt-sock"
|
uri = "qemu+ssh://{{ libvirt_host }}/system?socket=/var/run/libvirt/libvirt-sock"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user