move pc
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
- name: Install all software on infra01
|
- name: Install all software on infra01
|
||||||
hosts: infra01
|
hosts: infra01
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
become: true
|
||||||
|
|
||||||
collections:
|
collections:
|
||||||
- somaz94.ansible_k8s_iac_tool
|
- somaz94.ansible_k8s_iac_tool
|
||||||
@@ -19,6 +20,24 @@
|
|||||||
state: present
|
state: present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: Install dnf-plugins-core
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: dnf-plugins-core
|
||||||
|
state: present
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Install hashicorp repo
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
|
||||||
|
https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install terraform
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: terraform
|
||||||
|
state: present
|
||||||
|
become: true
|
||||||
|
|
||||||
# - name: Clone Git repository
|
# - name: Clone Git repository
|
||||||
# ansible.builtin.git:
|
# ansible.builtin.git:
|
||||||
# repo: "https://github.com/rblundon/homelab.git"
|
# repo: "https://github.com/rblundon/homelab.git"
|
||||||
@@ -28,3 +47,4 @@
|
|||||||
|
|
||||||
roles:
|
roles:
|
||||||
- install_kustomize
|
- install_kustomize
|
||||||
|
|
||||||
|
|||||||
40
dns-entry.yml
Normal file
40
dns-entry.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
# file: dns-entry.yml
|
||||||
|
|
||||||
|
- name: Master playbook for home lab
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Create DNS entry for {{ inventory_hostname }}
|
||||||
|
when: ip_address is defined
|
||||||
|
delegate_to: "{{ dns_server }}"
|
||||||
|
block:
|
||||||
|
- name: Check if terraform directory exists
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: ~/homelab/terraform/dns
|
||||||
|
register: terraform_dir
|
||||||
|
|
||||||
|
- name: Create Terraform directory for DNS entries
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: ~/homelab/terraform/dns
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
when: not terraform_dir.stat.exists
|
||||||
|
|
||||||
|
- name: Create Terraform file for host
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: templates/dns.tf.j2
|
||||||
|
dest: ~/homelab/terraform/dns/{{ inventory_hostname }}.tf
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: Update DNS entries via Terraform
|
||||||
|
delegate_to: "{{ dns_server }}"
|
||||||
|
community.general.terraform:
|
||||||
|
project_path: ~/homelab/terraform/dns/
|
||||||
|
variables:
|
||||||
|
freeipa_server: "{{ dns_server }}"
|
||||||
|
freeipa_admin: "{{ dns_admin }}"
|
||||||
|
freeipa_password: "{{ vault_freeipa_password }}"
|
||||||
|
state: present
|
||||||
|
force_init: true
|
||||||
@@ -1 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
# file: group_vars/all
|
||||||
|
|
||||||
|
# DNS variables
|
||||||
|
dns_server: "infra01.int.mk-labs.cloud"
|
||||||
|
dns_admin: "admin"
|
||||||
|
base_domain: "int.mk-labs.cloud"
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
freeipa_user: "admin"
|
#freeipa_user: "admin"
|
||||||
#freeipa_password: "{{ vault_freeipa_password }}"
|
#freeipa_password: "{{ vault_freeipa_password }}"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
cluster_name: "hub"
|
cluster_name: "hub"
|
||||||
cluster_version: "4.17.20"
|
cluster_version: "4.17.20"
|
||||||
base_domain: "int.mk-labs.cloud"
|
#base_domain: "int.mk-labs.cloud"
|
||||||
worker_node_count: 0
|
worker_node_count: 0
|
||||||
master_node_count: 1
|
master_node_count: 1
|
||||||
cluster_network: "10.128.0.0/14"
|
cluster_network: "10.128.0.0/14"
|
||||||
6
host_vars/pve01/vars
Normal file
6
host_vars/pve01/vars
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# file: host_vars/pve01/vars
|
||||||
|
# mac_address: "98:b7:85:1e:c6:f1"
|
||||||
|
ip_address: "10.1.71.51"
|
||||||
|
hostname: "pve01.{{ base_domain }}"
|
||||||
|
# primary_interface: "enp1s0f0"
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
|
# file: inventory.yml
|
||||||
proxmox:
|
proxmox:
|
||||||
hosts:
|
hosts:
|
||||||
pve01:
|
pve0[1:3]:
|
||||||
pve02:
|
|
||||||
pve03:
|
|
||||||
|
|
||||||
freeipa:
|
freeipa:
|
||||||
hosts:
|
hosts:
|
||||||
@@ -12,6 +11,6 @@ matchbox:
|
|||||||
hosts:
|
hosts:
|
||||||
infra01:
|
infra01:
|
||||||
|
|
||||||
hub-cluster:
|
hub_cluster:
|
||||||
hosts:
|
hosts:
|
||||||
ocp-hub:
|
ocp-hub:
|
||||||
|
|||||||
2
proxmox.yml
Normal file
2
proxmox.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# file: proxmox.yml
|
||||||
14
site.yml
Normal file
14
site.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
# file: site.yml
|
||||||
|
|
||||||
|
- name: Master playbook for home lab
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
connection: local
|
||||||
|
# roles:
|
||||||
|
# - dns-entry
|
||||||
|
|
||||||
|
# tasks:
|
||||||
|
|
||||||
|
- name: Process DNS entries
|
||||||
|
ansible.builtin.import_playbook: dns-entry.yml
|
||||||
11
templates/dns.tf.j2
Normal file
11
templates/dns.tf.j2
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// Terraform DNS entry template
|
||||||
|
|
||||||
|
resource "freeipa_dns_record" "{{ inventory_hostname }}" {
|
||||||
|
zone_name = "{{ base_domain }}."
|
||||||
|
name = "{{ inventory_hostname }}"
|
||||||
|
type = "A"
|
||||||
|
records = [
|
||||||
|
"{{ hostvars[inventory_hostname].ip_address }}",
|
||||||
|
]
|
||||||
|
ttl = 60
|
||||||
|
}
|
||||||
32
terraform/dns/provider.tf
Normal file
32
terraform/dns/provider.tf
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Configure the DNS Provider
|
||||||
|
provider "freeipa" {
|
||||||
|
host = "infra01.int.mk-labs.cloud"
|
||||||
|
username = "admin"
|
||||||
|
password = var.freeipa_password
|
||||||
|
insecure = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "freeipa_server" {
|
||||||
|
description = "The server for the FreeIPA provider"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "freeipa_admin" {
|
||||||
|
description = "The admin username for the FreeIPA provider"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "freeipa_password" {
|
||||||
|
description = "The password for the FreeIPA provider"
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
freeipa = {
|
||||||
|
source = "rework-space-com/freeipa"
|
||||||
|
version = "5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user