Move ansible to it's own directory structure

This commit is contained in:
2025-07-30 12:41:18 -05:00
parent 0764cc8bd7
commit 48b8548528
66 changed files with 0 additions and 6 deletions

View File

@@ -0,0 +1,17 @@
---
# file: group_vars/all
# Proxmox variables
proxmox_user: "root@pam"
proxmox_password: "{{ vault_proxmox_root_password }}"
proxmox_host: "pve01"
# DNS variables
dns_server: "infra01" # .int.mk-labs.cloud"
dns_admin: "admin"
base_domain: "int.mk-labs.cloud"
# DHCP server
dhcp_server: "matchbox"
# Terraform variables
terraform_server: "infra01"

View File

@@ -0,0 +1,155 @@
$ANSIBLE_VAULT;1.1;AES256
33636666323832646139323162666263383232643233633539303464363730636163343162663930
6132323032626433306635626239643764653966316262650a316366343264303835633063613961
38386666623865633236616364303864663133396562313664313030393435613065636265383333
6366643932666265610a373331363731343531363763626337313664633933383163363635336136
35376131363764616139333734623930373233653961383535623861373361643433313761623663
32633836333063313630633936346366306637323638326337376630646435306163366262373037
66613765633463333934373264633332333532376461313137333133356333313964663233313632
35396630396135643761336237636463313233623064316233666237343562343936346530393230
66616638316665353232353738616532393638396364313433646134373336313631396633313731
32363361366563643039383735643132643465326331613564306261376332656136656438313738
33316432633231313837376238396538666562323662393634393661643966393262323238363639
66366564356431653664633663366564303561313134653866396134386561396635343230643331
38346661333436356237323136306238636337396266363265393865363535636164633036613730
30386637363834633934343839323238366639383964646531393862363363626538303035343938
38323166653835343961653664666432616162386532353563346663373536613233623035643431
35323136643236366463646365343266383937643062363232336435616134666338646361383864
37393633313531643064643336646161323930363032356630313438396134646361373466396533
33653335316162373832336665353334613031316436393664343963316330333062633737636264
63343766666639626235623535316432373431363931623432643566366130303166353866376464
38313332613333656236333832363136323563633966386666323666396536336637373562383962
31643966383465356464306530623437663139633761316161313532656662616139323461636133
39336534366632363935386236353336656239363131313333653966633561396230613665613261
35383735323237323838366637313765623132346230393633653063613034373263353866613734
39316431306430316536346334623563653762333030656632336537363562666265316633373836
33383766363361616663376630356561323565316531623138356135353139616465663138373634
31326539626331383839343332653230653337393031353934663634386133616437633834383437
61663561353837353831363931663434363137326264613465366438323763303465366238643233
37646337323363333166643366363434366336383736623561616665613232643438356432626363
35616162663730636163383233633263626435626331343635663130303633643538373136653936
65323731316464326364343061353561623535653530623636396165343134393865666133356466
37643137306235663635643166363364323135613736363261393739376531363863653136313133
30306566346533343963386432396431393738396531373862316461633765353766646533326461
36316430326430353333306261353633343035383139303866656431626364646636656131363332
31396635663362373731313265643336626266306333336130323761383262333032626662346666
62356635393032393837356166306335326462393365346639623237346438353637323038613834
64633439633237666131646664326531343836393538376237363338626634336431663561353663
35343837366263353635396538626262653930653961393166646261393763643135386630653666
34373464663065656365336536666631663831363832333136653065626436356266633735663834
32343133623835353062353733663530323138666232633961393365393563326462653164633266
32353839393635616661646133356538373938613232303837326439623839333637313138666535
38316161633365376438616261663463386334633436353530663965376432313834396638306237
36613665383965636533353532396566343661633763363638343064393031653230393037666166
30613039376365666236366263623361643266633236336633386438663938663938656565316136
36656237376366616163623334316130383363393834643033363338343362313863313638383433
63313264336632316663306665653630376266656233353439646637356365353063613961376231
61643137623365393132353462386134333430663466666165613937333964373230396535393134
30396134616463656464343637656562646165396635353066646633373832356261626634366138
62326138343435666662396630363136393634306335653063396134383731383165663432373131
34326363643037326465326435616164393033363565366135313133393866396136356137663139
66316138663732393430633338346136353738626534633164623830663734343337636562316538
61323566326434643036363866363263616435356466303464653131633937353233376539616465
36303738343262373761326538616632393761383662656231336434383334333735613264393662
37653336336666333765663434393765313664316332643030333464376566306666323833663036
62653964643532306436626261363161633937323835663036343133353065313866373639313633
31663635376266653639626365383430346666363262666638323564353661386137313865653337
62306530383332343931653137353139363236393137613437663333633664653230306264316432
61353132656564383437386237323765393034393237376531343331623966343636626534616232
61613538396636633737643331663333336666313966633739633936333535376264346231363939
39353133396562623466646237303639313665613863633531396235306166333936373733396532
32663737363765663638633739336438613663363430386338373361306636313366356135363362
62316666356331623965333930336566393032386364336266636338323337353661653638663663
38623463353061663134313265323530346266636665373833653461353237366135623832643732
65613231646431373537636663386237613435373734633763306434393133653133333830626365
62376166316639366161616635616234316234383230376539616337656637663332306136333662
35396166303166373163383836303963343434343735383665376533613532363331613437656164
38386336653361633866623136666131356537303038343061313034623761656234396266306233
33616338393662303737643932653738303438393335623162363732363339363231396432343361
30646539306332333639343737326366653433386363373033363562353535623431316363363736
64663863653664366136643234626261653039393031363161333337643166366634303631633261
30323866643266333132326564376263333434343565343738613632393838346331616165663766
32343735316334653136393838363763333939646261646333633030383932373461373266346134
36306336346339646639326333353531393563323265303936663036653334333065313033613936
63643036336562346261316434646539333163323233393638636165383935633535366637623431
34373731306436613964646138353539393231633336373937613165636535613731353830616535
63326632303662323433656133626266613566663730386532393431333862656239646633663663
66353363663135613761616136326134633538373661396666643832376137346132666232623939
66323139623332393834633532396230666463656637336634356365363731633061646631326434
39353134303932313134313836653163383566653832643435653166396533353062373537616234
31316432623439303261353333643130653562366666306239633139313939303330346130663637
30656238626131343131363530306431336366303735653532666231656531343230306232393130
30343537343064626531343530373435373561623231336539373331316231366461616464383461
37326139633636656632663362613530636436323832613633336339346634616239386363363964
61383538636433316133323263326265313661646439393162393735313036363361653638353665
62326565343431343962316339653237613735643934363661326534643663383666343165653937
66633863666537663366653565386335663663353863666632316334306562656666666532326666
36376435373530303530666535356435663735353233633561306564326231653563663862303137
61616432366566333733333765356561613538383836363338386435373561626133303938353735
39333236346135343930393930353433393136613537383736356661383133623334636263383130
32626431333532326238373466663732346331393463643936343635303837623531356334383031
36326364333266633938386330623833356662373634363865306162666639613537376130363534
33393566356137353539633932643065313733633838336531306433633063306635616163363064
35646436646633373834343561383237633131643233326133663835383838616162333831363766
38376265333835373836343964633366623561386565623734373661333238646630326439643539
65306366333863636634623763356534323132346566393733633564643966663962653236363933
61336233383133616138303661623764303865313230366162653066623737383261363633623339
30666230343830323634363465313132623132336436346138386266383364363131613433646435
38333332326363326262353234376434656231336136366430303434303032623238633362343330
37333935626264353637666666316564653966376365373464616563353861343166316165303563
39653763393131356661386634653237633130663533356234656465356533343963653330356137
35353763373363313061653637333166323834333033653332316432623938393966303632383065
63656237616231636564386438333564613935313835326536383064656464363261643164623863
64356435626539623230323132333364386362323533303961396337336438353264643265626464
66666266613036613835313130646638613532373062663132326162396636623931363734613262
39396232646235666130386334633665643833326138663534376562393936616264623161626164
62663361336466636436383663663132356161393462373263373132633835663730346231396166
33363738343531653636313236666231393538653934613639383366386136386133623937626337
61373333366630396162656138343537363338326239373938376465376538666236313932373364
34333165393331313331393736623362366637383231666664383133323135646163306639396162
62353366343839666333376530326334303936666139383936363462393566653732353431656530
33336237666535646565383731333966626632383661653666316339623631373532383937643932
65373535626537393632333366613530393265323763316533386335343737313462343562333338
30663130623633376465333665333738653566656237323563653230653130653938373966626635
34356432303938613231316663326662333733363036333265393233343862356233383961323464
30346162383137373735646336343463376534383235626233306538373463366264393130663066
32333236313531613238396136343538343439343062353266643838363136343433623837313631
64313865383762396231643265613839643539306137363834373165313832633631373234626439
61333533383236333432613564643431613039366661663262626330376133616331363037343838
34336365663730356433613734393639333139323436316635656539626261326336343039666262
61653766363430383037326532323834373663346563393766313335383531323537626537643335
32373034636461353635643731346239333634353361326237303134666632383266303166363932
39653734636137393635343131383766356136383965336536343039613266373738393737643564
66353766666633626261653863363331386534663965333130353764396263323536316162643730
36386162613537626164386335363737613361653831376265623939633362343065626633363363
35323166663634373563396234663263363064363930656434323864616463613233666632363635
37623565646131633433386633376230643332626564333565373362363561656366393931366231
38356131343837663031366133666263633330656339633237376362323765373064323236653264
36333163393565393138306435353839343062356530633966633235656531616363313432636163
33323934323731323338383230393465646664396535353535336130363864306631353164373238
35383637653161356233306165363564636130613538663363653134643439393931393266323564
37336534353836656462393339623333363132663539313665626462303866316463626330373733
31363636363038636661373062383762323335326163353634643237393563303139643034636532
30643836306262393335376461333762346439646433643037393438353339653730393830383935
61326333643862333365636535396433313235666433333563656330663763353833326630356164
65346636393061653039643436353763343839326131383534663137313637313265666431666461
38656634633731303036376537313465393234616436353566396338393534613935656561666133
33613936336530303763616664323433656362643334343061333563656634313864633032616366
62363133336138613366313135643633643135613963303466633330303633626435373632303938
62613332353033396636333365346439373539343037313065333733613962343737336531636537
36646233623463343530346162346230343037323366363730376532326633323334663765323762
66616138313434623032623437343438343530363132613564353532363235643962306162643035
33633234613336386234653036333462336539356530393032303662323032616536323264363862
37626437353232393335373765333732616532383333373438623439393932613330373264393731
62633936303436656661303130336363633637666531343263373633663334386434393762633732
36333430653037643339363330376163396132343830396161643864376436393964646264636239
33623733303163316137616533646462633866343932656539383363333631316338653239343734
32666130633238313763313437643038616430363566313337363465353335353630333362373265
38363338383261663636366233346262333431393766613236383830393662363033326535376137
64666338343630373066663363393939383436623535663362656637323833363061313936343831
36353166666239303032666466333662613935393634663534646534313766316533666539626636
64353063373539363136303731313130343439643562623433636630616238343339346362383036
30353031353366343332613461623837353736316665316234643235366661626464386534353332
30313662313665343138656430353562343366626130383639663964396633343865613333363233
65303831343537393834663930303164653164376466336562333633623039613734663132333665
6636323466636239373237353264623363383330623932373133

View File

@@ -0,0 +1,3 @@
---
#freeipa_user: "admin"
#freeipa_password: "{{ vault_freeipa_password }}"

View File

@@ -0,0 +1,51 @@
# file: group_vars/hub_cluster/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Name of the OpenShift Cluster
cluster_name: "hub"
# Version of OpenShift to install. All available versions can be found at: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/
cluster_version: "4.17.20"
# Type of cluster.
# - none (Single Node Cluster)
# - baremetal (Traditional and Compact Cluster)
platform_type: "none"
# Number of nodes to deploy
# - Master: 1; Worker 0 (Single Node Cluster)
# - Master: 3; Worker 0 (Compact Cluster)
# - Master: 3; Worker 1-3 (Traditional Cluster)
master_node_count: 1
worker_node_count: 0
# Subnet that cluster nodes will reside on.
machine_network: "10.1.71.0/24"
# OpenShift API IP Address (Comment out for Single Node Cluster)
# api_address: "10.1.71.10"
# OpenShift Apps Wildcard IP Address (Comment out for Single Node Cluster)
# app_address: "10.1.71.10"
# These are internal networks to the cluster and should not need to be changed.
cluster_network: "10.128.0.0/14"
cluster_network_host_prefix: 23
service_network: "172.30.0.0/16"
# Static Variables
openshift_installer_file: "openshift-install-linux.tar.gz"
openshift_client_file: "openshift-client-linux.tar.gz"
openshift_installer_download_url: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/{{ cluster_version }}/{{ openshift_installer_file }}"
openshift_client_download_url: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/{{ cluster_version }}/{{ openshift_client_file }}"

View File

@@ -0,0 +1,51 @@
# file: group_vars/internal_cluster/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Name of the OpenShift Cluster
cluster_name: "openshift"
# Version of OpenShift to install. All available versions can be found at: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/
cluster_version: "4.18.21"
# Type of cluster.
# - none (Single Node Cluster)
# - baremetal (Traditional and Compact Cluster)
platform_type: "baremetal"
# Number of nodes to deploy
# - Master: 1; Worker 0 (Single Node Cluster)
# - Master: 3; Worker 0 (Compact Cluster)
# - Master: 3; Worker 1-3 (Traditional Cluster)
master_node_count: 3
worker_node_count: 1
# Subnet that cluster nodes will reside on.
machine_network: "10.1.71.0/24"
# OpenShift API IP Address
api_address: "10.1.71.69"
# OpenShift Apps Wildcard IP Address (These will be the same in a Single Node Cluster)
app_address: "10.1.71.60"
# These are internal networks to the cluster and should not need to be changed.
cluster_network: "10.128.0.0/14"
cluster_network_host_prefix: 23
service_network: "172.30.0.0/16"
# Static Variables
openshift_installer_file: "openshift-install-linux.tar.gz"
openshift_client_file: "openshift-client-linux.tar.gz"
openshift_installer_download_url: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/{{ cluster_version }}/{{ openshift_installer_file }}"
openshift_client_download_url: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/{{ cluster_version }}/{{ openshift_client_file }}"

View File

@@ -0,0 +1,14 @@
---
ipaadmin_password: "{{ vault_ipaadmin_password }}"
ipadm_password: "{{ vault_ipadm_password }}"
ipaserver_domain: int.mk-labs.cloud
ipaserver_realm: INT.MK-LABS.CLOUD
ipaserver_setup_firewalld: true
ipaserver_setup_dns: true
ipaserver_forwarders: 1.1.1.1,1.0.0.1
ipaserver_random_serial_numbers: true
#dns_ip_addresses: "{{ ansible_hostname }}"
#dns_reverse_zones:
#domain: int.mk-labs.cloud
forwarders: 1.1.1.1,1.0.0.1
#hostname: "{{ hostname }}"

View File

@@ -0,0 +1,4 @@
---
#freeipa_user: "admin"
ipaadmin_password: "{{ vault_freeipa_password }}"
ipaserver_domain: "int.mk-labs.cloud"

View File

@@ -0,0 +1,9 @@
---
# Variables for Matchbox
assets: "/var/lib/matchbox/assets"
http_endpoint: "http://matchbox.int.mk-labs.cloud:8080"
rpc_endpoint: "matchbox.int.mk-labs.cloud:8081"
# Variables for OpenShift Installer
#openshift_installer_pull_secret: "{{ vault_pull_secret }}"
#openshift_installer_ssh_key: "{{ vault_ssh_key }}"

View File

@@ -0,0 +1,54 @@
# file: group_vars/openshift_cluster_template/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Role of this node in the cluster.
# - master
# - worker
# Name of the OpenShift Cluster
cluster_name: "openshift"
# Version of OpenShift to install. All available versions can be found at: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/
cluster_version: "4.18.21"
# Type of cluster.
# - none (Single Node Cluster)
# - baremetal (Traditional and Compact Cluster)
platform_type: "baremetal"
# Number of nodes to deploy
# - Master: 1; Worker 0 (Single Node Cluster)
# - Master: 3; Worker 0 (Compact Cluster)
# - Master: 3; Worker 1-3 (Traditional Cluster)
master_node_count: 3
worker_node_count: 1
# Subnet that cluster nodes will reside on.
machine_network: "10.1.71.0/24"
# OpenShift API IP Address (Comment out for Single Node Cluster)
api_address: "10.1.71.69"
# OpenShift Apps Wildcard IP Address (Comment out for Single Node Cluster)
app_address: "10.1.71.60"
# These are internal networks to the cluster and should not need to be changed.
cluster_network: "10.128.0.0/14"
cluster_network_host_prefix: 23
service_network: "172.30.0.0/16"
# Static Variables
openshift_installer_file: "openshift-install-linux.tar.gz"
openshift_client_file: "openshift-client-linux.tar.gz"
openshift_installer_download_url: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/{{ cluster_version }}/{{ openshift_installer_file }}"
openshift_client_download_url: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/{{ cluster_version }}/{{ openshift_client_file }}"

View File

@@ -0,0 +1,77 @@
---
# Variables for Unbound https://github.com/aruhier/ansible-role-unbound
### Server ###
unbound_chroot: '""'
unbound_num_threads: 2
unbound_interfaces:
- "{{ ip_address }}"
#unbound_do_ip4: "yes"
unbound_do_ip6: "no"
#unbound_do_udp: "yes"
#unbound_do_tcp: "yes"
# list of strings, as the order impact how policies are interpreted
unbound_outgoing_policies: []
unbound_access_control:
- '192.168.1.0/24 allow'
- '192.168.3.0/24 allow'
- '192.168.5.0/24 allow'
- '192.168.10.0/24 allow'
- '10.1.71.0/24 allow'
unbound_access_control_tag: []
unbound_access_control_tag_action: []
unbound_access_control_tag_data: []
unbound_access_control_view: []
unbound_private_addresses:
- '192.168.1.0/24'
- '192.168.3.0/24'
- '192.168.5.0/24'
- '192.168.10.0/24'
- '10.1.71.0/24'
unbound_private_domains:
- 'mk-labs.cloud'
unbound_domains_insecure: []
unbound_do_not_query_addresses: []
unbound_local_zones: []
unbound_local_datas: []
unbound_local_data_ptrs: []
unbound_local_zone_tags: []
unbound_local_zone_overrides: []
unbound_trust_anchors: []
unbound_trusted_keys_files: []
### Remote Control ###
unbound_control_enable: "no"
unbound_control_interface: []
### Stub, forward zones and others ###
unbound_rpz_zones: [] # list of dicts
unbound_stub_zones: [] # list of dicts
unbound_forward_zones:
- name: 'int.mk-labs.cloud'
forward-addr:
- '10.1.71.5'
- name: '.'
forward-addr:
- '1.0.0.1@53#one.one.one.one'
- '1.1.1.1@53#one.one.one.one'
# For stub and forward zones, if a key inside one of the dict is an iterable,
# it will iterate inside it to duplicate the option with all the contained
# values.
# Can be useful in case of multiple forward-addr for a same zone:
# Example:
# unbound_forward_zones:
# - {name: "test.tld", "forward-addr": ["192.0.2.5", "192.0.2.6"]}
unbound_views: [] # list of strings, as options can be multiples

View File

@@ -0,0 +1,6 @@
---
# file: host_vars/backup/vars
# mac_address: "98:b7:85:1e:c6:f1"
ip_address: "10.1.71.9"
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# primary_interface: "enp1s0f0"

View File

@@ -0,0 +1,11 @@
---
# file: host_vars/docker01/vars
# Networking
# primary_interface: "enp1s0f0"
#mac_address: "BC:24:11:03:A9:7B"
ip_address: 10.1.71.211
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# Software
#terraform_version: "1.11.3"

View File

@@ -0,0 +1,11 @@
---
# file: host_vars/infra01/vars
# Networking
# primary_interface: "enp1s0f0"
# mac_address: "98:b7:85:1e:c6:f1"
#ip_address: 10.1.71.51
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# Software
terraform_version: "1.11.3"

View File

@@ -0,0 +1,29 @@
---
# file: host_vars/int-master01/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Role of this node in the cluster.
# - master
# - worker
node_role: "master"
# IP address assigned to this node on the Primary Interface
ip_address: 10.1.71.61
# Ansible Playbook supports booting node via one interface, but installing on a
# different interface. (Disabling the boot interface on install) All these fields
# are necessary. In the case of a single NIC node, interfaces and MAC addresses
# should be the same.
boot_interface: "enp0s31f6"
boot_mac_address: "54:bf:64:60:52:2d"
primary_interface: "enp1s0f0"
install_mac_address: "98:b7:85:20:47:22"
# Static Variables
hostname: "{{ inventory_hostname }}.{{ base_domain }}"

View File

@@ -0,0 +1,29 @@
---
# file: host_vars/int-master02/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Role of this node in the cluster.
# - master
# - worker
node_role: "master"
# IP address assigned to this node on the Primary Interface
ip_address: 10.1.71.62
# Ansible Playbook supports booting node via one interface, but installing on a
# different interface. (Disabling the boot interface on install) All these fields
# are necessary. In the case of a single NIC node, interfaces and MAC addresses
# should be the same.
boot_interface: "enp0s31f6"
boot_mac_address: "54:bf:64:5f:a2:80"
primary_interface: "enp1s0f0"
install_mac_address: "98:b7:85:20:47:3a"
# ---
hostname: "{{ inventory_hostname }}.{{ base_domain }}"

View File

@@ -0,0 +1,29 @@
---
# file: host_vars/int-master03/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Role of this node in the cluster.
# - master
# - worker
node_role: "master"
# IP address assigned to this node on the Primary Interface
ip_address: 10.1.71.63
# Ansible Playbook supports booting node via one interface, but installing on a
# different interface. (Disabling the boot interface on install) All these fields
# are necessary. In the case of a single NIC node, interfaces and MAC addresses
# should be the same.
boot_interface: "enp0s31f6"
boot_mac_address: "d8:9e:f3:4c:02:a9"
primary_interface: "enp1s0f0"
install_mac_address: "98:b7:85:1f:89:cf"
# ---
hostname: "{{ inventory_hostname }}.{{ base_domain }}"

View File

@@ -0,0 +1,29 @@
---
# file: host_vars/int-worker02/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Role of this node in the cluster.
# - master
# - worker
node_role: "worker"
# IP address assigned to this node on the Primary Interface
ip_address: 10.1.71.65
# Ansible Playbook supports booting node via one interface, but installing on a
# different interface. (Disabling the boot interface on install) All these fields
# are necessary. In the case of a single NIC node, interfaces and MAC addresses
# should be the same.
boot_interface: "enp87s0"
boot_mac_address: "58:47:ca:76:13:49"
primary_interface: "enp2s0f0"
install_mac_address: "58:47:ca:76:13:47"
# ---
hostname: "{{ inventory_hostname }}.{{ base_domain }}"

View File

@@ -0,0 +1,11 @@
---
# file: host_vars/matchbox/vars
# Networking
# primary_interface: "enp1s0f0"
# mac_address: "98:b7:85:1e:c6:f1"
ip_address: 10.1.71.7
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# Software
#terraform_version: "1.11.3"

View File

@@ -0,0 +1,17 @@
---
# file: host_vars/monitor/vars
# VM Definition
platform: "proxmox"
proxmox_clone_node: "pve03"
vm_clone_source: "fedora-42-large"
vm_storage: "pve-general"
ha_group: "pve03"
# Networking
ip_address: 10.1.71.249
# Software
#terraform_version: "1.11.3"
hostname: "{{ inventory_hostname }}.{{ base_domain }}" #change variable to fqdn

View File

@@ -0,0 +1,11 @@
---
# file: host_vars/matchbox/vars
# Networking
# primary_interface: "enp1s0f0"
mac_address: "BC:24:11:1B:BB:92"
ip_address: 10.1.71.81
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# Software
#terraform_version: "1.11.3"

View File

@@ -0,0 +1,5 @@
---
mac_address: "98:b7:85:1e:c6:f1"
ip_address: "10.1.71.10"
hostname: "ocp-hub"
primary_interface: "enp1s0f0"

View File

@@ -0,0 +1,29 @@
---
# file: host_vars/openshift_node_template/vars
# Ansible vars template for OpenShift nodes created via Ansible (configure_openshift_cluster).
# Cluster deployed via Agent Installer and Matchbox (iPXE):
# Role of this node in the cluster.
# - master
# - worker
node_role: "master"
# IP address assigned to this node on the Primary Interface
ip_address: 10.1.71.61
# Ansible Playbook supports booting node via one interface, but installing on a
# different interface. (Disabling the boot interface on install) All these fields
# are necessary. In the case of a single NIC node, interfaces and MAC addresses
# should be the same.
boot_interface: "enp0s31f6"
boot_mac_address: "54:bf:64:60:52:2d"
primary_interface: "enp1s0f0"
install_mac_address: "98:b7:85:20:47:22"
# Static Variables
hostname: "{{ inventory_hostname }}.{{ base_domain }}" # Change variable to fqdn

View File

@@ -0,0 +1,7 @@
---
# file: host_vars/pve01/vars
# mac_address: "98:b7:85:1e:c6:f1"
#ip_address: "10.1.71.51"
ip_address: "10.10.21.51"
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# primary_interface: "enp1s0f0"

View File

@@ -0,0 +1,7 @@
---
# file: host_vars/pve02/vars
# mac_address: "98:b7:85:1e:c6:f1"
#ip_address: "10.1.71.52"
ip_address: "10.10.21.52"
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# primary_interface: "enp1s0f0"

View File

@@ -0,0 +1,7 @@
---
# file: host_vars/pve03/vars
# mac_address: "98:b7:85:1e:c6:f1"
#ip_address: "10.1.71.53"
ip_address: "10.10.21.53"
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# primary_interface: "enp1s0f0"

View File

@@ -0,0 +1,11 @@
---
# file: host_vars/matchbox/vars
# Networking
# primary_interface: "enp1s0f0"
mac_address: "BC:24:11:1C:95:1B"
ip_address: 10.1.71.91
hostname: "{{ inventory_hostname }}.{{ base_domain }}"
# Software
#terraform_version: "1.11.3"

View File

@@ -0,0 +1,47 @@
---
# file: host_vars/unbound01/vars
# Supported hypervisors:
# - Proxmox
platform: "proxmox"
# This is the Proxmox node where all the VM templates are stored. (Templates are not global.)
proxmox_clone_node: "pve03"
# Templates are named in the following format (all lower case): <OS Distribution>-<OS Version>-<VM Size>
# Current OS offerings are:
# - Fedora (42)
# Current VM sizes are:
# - Small: 2 cores, 2GB memory, 8 GiB virtual disk
# - Medium: 2 cores, 4GB memory, 16 GiB virtual disk
# - Large: 4 cores, 4GB memory, 32 GiB virtual disk
# - Xlarge: 4 cores, 8GB memory, 64 GiB virtual disk
vm_clone_source: "fedora-42-small"
# Proxmox storage target.
vm_storage: "pve-general"
# Proxmox does not yet do dynamic load balancing, the host target sets the target for HA groups
# and backup groups. (ha_group will be factored out in the next functionality update.)
ha_group: "pve03"
proxmox_host_target: "pve03"
# Currently, only single NIC VMs using IPv4 are supported via cloning. The IP address also
# sets the Proxmox VMID. The VMID is a combination of the 3rd and 4th octet of the IPv4 address.
ip_address: 10.1.71.251
# Software
# Future enhancement will allow specification of additional software to automatically deploy to
# the VM after creation.
#terraform_version: "1.11.3"
# ---
hostname: "{{ inventory_hostname }}.{{ base_domain }}" # Change variable to fqdn

View File

@@ -0,0 +1,47 @@
---
# file: host_vars/unbound02/vars
# Supported hypervisors:
# - Proxmox
platform: "proxmox"
# This is the Proxmox node where all the VM templates are stored. (Templates are not global.)
proxmox_clone_node: "pve03"
# Templates are named in the following format (all lower case): <OS Distribution>-<OS Version>-<VM Size>
# Current OS offerings are:
# - Fedora (42)
# Current VM sizes are:
# - Small: 2 cores, 2GB memory, 8 GiB virtual disk
# - Medium: 2 cores, 4GB memory, 16 GiB virtual disk
# - Large: 4 cores, 4GB memory, 32 GiB virtual disk
# - Xlarge: 4 cores, 8GB memory, 64 GiB virtual disk
vm_clone_source: "fedora-42-small"
# Proxmox storage target.
vm_storage: "pve-general"
# Proxmox does not yet do dynamic load balancing, the host target sets the target for HA groups
# and backup groups. (ha_group will be factored out in the next functionality update.)
ha_group: "pve03"
proxmox_host_target: "pve03"
# Currently, only single NIC VMs using IPv4 are supported via cloning. The IP address also
# sets the Proxmox VMID. The VMID is a combination of the 3rd and 4th octet of the IPv4 address.
ip_address: 10.1.71.252
# Software
# Future enhancement will allow specification of additional software to automatically deploy to
# the VM after creation.
#terraform_version: "1.11.3"
# ---
hostname: "{{ inventory_hostname }}.{{ base_domain }}" # Change variable to fqdn

View File

@@ -0,0 +1,48 @@
---
# file: host_vars/vm_template/vars
# Ansible vars template for hosts created via cloning.
# Supported hypervisors:
# - Proxmox
platform: "proxmox"
# This is the Proxmox node where all the VM templates are stored. (Templates are not global.)
proxmox_clone_node: "pve03"
# Templates are named in the following format (all lower case): <OS Distribution>-<OS Version>-<VM Size>
# Current OS offerings are:
# - Fedora (42)
# Current VM sizes are:
# - Small: 2 cores, 2GB memory, 8 GiB virtual disk
# - Medium: 2 cores, 4GB memory, 16 GiB virtual disk
# - Large: 4 cores, 4GB memory, 32 GiB virtual disk
# - Xlarge: 4 cores, 8GB memory, 64 GiB virtual disk
vm_clone_source: "fedora-42-large"
# Proxmox storage target.
vm_storage: "pve-general"
# Proxmox does not yet do dynamic load balancing, the host target sets the target for HA groups
# and backup groups. (ha_group will be factored out in the next functionality update.)
ha_group: "pve03"
proxmox_host_target: "pve03"
# Currently, only single NIC VMs using IPv4 are supported via cloning. The IP address also
# sets the Proxmox VMID. The VMID is a combination of the 3rd and 4th octet of the IPv4 address.
ip_address: 10.1.71.249
# Software
# Future enhancement will allow specification of additional software to automatically deploy to
# the VM after creation.
#terraform_version: "1.11.3"
# ---
hostname: "{{ inventory_hostname }}.{{ base_domain }}" # Change variable to fqdn

76
ansible/inventory.yml Normal file
View File

@@ -0,0 +1,76 @@
# file: inventory.yml
proxmox:
hosts:
pve0[1:3]:
dhcp_server:
hosts:
matchbox:
unbound_servers:
hosts:
unbound01:
unbound02:
backup_servers:
hosts:
backup:
freeipa:
hosts:
infra01:
prometheus_server:
hosts:
monitor:
node_explorer:
hosts:
monitor:
alertmanager:
hosts:
monitor:
grafana:
hosts:
monitor:
ipaserver:
hosts:
infra01.int.mk-labs.cloud:
matchbox_server:
hosts:
matchbox:
hub_cluster:
hosts:
ocp-hub:
internal_cluster:
hosts:
int-master01:
int-master02:
int-master03:
int-worker02:
sql_servers:
hosts:
sql01:
n8n_servers:
hosts:
n8n:
docker_servers:
hosts:
docker01:
observer:
hosts:
prometheus:
target:
hosts:
prometheus:

View File

@@ -0,0 +1,39 @@
---
- name: Add entry to DNSMasq
hosts: all
gather_facts: false
tasks:
- name: Retrieve information about specific VM by name and get current configuration
delegate_to: "localhost"
community.proxmox.proxmox_vm_info:
api_user: "{{ proxmox_user }}"
api_password: "{{ proxmox_password }}"
api_host: "{{ proxmox_host }}"
name: "{{ inventory_hostname }}"
config: current
register: proxmox_vm_info
- name: Extract net0 information
ansible.builtin.set_fact:
vm_net0: "{{ proxmox_vm_info.proxmox_vms[0].config.net0 }}"
- name: Extract MAC address using regex
ansible.builtin.set_fact:
vm_mac_address: "{{ vm_net0 | regex_search('([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}') }}"
- name: Add line to hosts file
delegate_to: "{{ groups['dhcp_server'][0] }}"
become: true
ansible.builtin.lineinfile:
path: /etc/dnsmasq.d/hosts.conf
regexp: "# {{ inventory_hostname }}$"
line: "dhcp-host={{ vm_mac_address | lower }},{{ ip_address }} # {{ inventory_hostname }}"
state: present
# restart dnsmasq service
- name: Restart service dnsmasq
delegate_to: "{{ groups['dhcp_server'][0] }}"
become: true
ansible.builtin.service:
name: dnsmasq
state: restarted

View File

@@ -0,0 +1,17 @@
---
- name: Add entry to DNS
hosts: all
gather_facts: false
tasks:
- name: Create DNS entry for {{ inventory_hostname }}
delegate_to: "{{ groups['ipaserver'][0] }}"
freeipa.ansible_freeipa.ipadnsrecord:
ipaapi_context: "server"
ipaadmin_password: "{{ vault_freeipa_password }}"
name: "{{ inventory_hostname }}"
zone_name: "{{ base_domain }}"
record_type: "A"
record_value: "{{ ip_address }}"
record_ttl: 60
# create_reverse: yes

View File

@@ -0,0 +1,218 @@
---
- name: Configure DNS entries for cluster nodes
hosts: internal_cluster
gather_facts: false
become: true
tasks:
- name: Create DNS entry for each cluster node
ansible.builtin.include_tasks: tasks/create_dns_record.yml
vars:
host_ip_address: "{{ ip_address }}"
- name: Configure DNS entries for OpenShift cluster services
hosts: internal_cluster[0]
gather_facts: false
become: true
tasks:
- name: Create DNS entries for OpenShift cluster services
ansible.builtin.include_tasks: tasks/create_dns_record.yml
vars:
dns_name: "{{ item.name }}"
dns_address: "{{ item.address }}"
loop:
- name: "api.{{ cluster_name }}"
address: "{{ api_address }}"
- name: "api-int.{{ cluster_name }}"
address: "{{ api_address }}"
- name: "*.apps.{{ cluster_name }}"
address: "{{ app_address }}"
loop_control:
label: "{{ item.name }}"
- name: Configure DHCP entries for cluster nodes
hosts: internal_cluster
gather_facts: false
become: true
tasks:
- name: Configure DHCP entry for node
ansible.builtin.include_tasks: tasks/configure_dhcp_entry.yml
vars:
host_mac_address: "{{ install_mac_address }}"
host_ip_address: "{{ ip_address }}"
handlers:
- name: Restart dnsmasq
delegate_to: "{{ dhcp_server }}"
become: true
ansible.builtin.service:
name: dnsmasq
state: restarted
- name: Create OpenShift installer files
hosts: matchbox
gather_facts: true
vars:
cluster_group: "internal_cluster"
download_dir: "/var/cache/openshift-install"
tasks:
- name: Remove previous directory
ansible.builtin.file:
path: ~/homelab/terraform/{{ cluster_group }}
state: absent
- name: Create directory
ansible.builtin.file:
path: ~/homelab/terraform/{{ cluster_group }}
state: directory
mode: '0755'
- name: OpenShift Installer install-config.yaml
ansible.builtin.template:
src: templates/install-config.yaml.j2
dest: ~/homelab/terraform/{{ cluster_group }}/install-config.yaml
mode: '0644'
- name: OpenShift Installer agent-config.yaml
ansible.builtin.template:
src: templates/agent-config.yaml.j2
dest: ~/homelab/terraform/{{ cluster_group }}/agent-config.yaml
mode: '0644'
- name: Create directory for OpenShift Installer files
become: true
ansible.builtin.file:
path: "{{ download_dir }}/{{ hostvars[groups[cluster_group][0]].cluster_version }}"
state: directory
mode: '0755'
owner: root
group: root
- name: Check if OpenShift installer file exists
ansible.builtin.stat:
path: "{{ download_dir }}/{{ hostvars[groups[cluster_group][0]].cluster_version }}/{{ hostvars[groups[cluster_group][0]].openshift_installer_file }}"
register: openshift_installer_file
- name: Download and install OpenShift installer package
when: not openshift_installer_file.stat.exists
block:
- name: Download OpenShift Installer file
become: true
ansible.builtin.get_url:
url: "{{ hostvars[groups[cluster_group][0]].openshift_installer_download_url }}"
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
mode: '0644'
- name: Unarchive installer file
become: true
ansible.builtin.unarchive:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/openshift-install-linux.tar.gz
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
remote_src: true
- name: Copy install binary
become: true
ansible.builtin.copy:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/openshift-install
dest: /usr/local/bin
remote_src: true
owner: wed
group: wed
mode: '0755'
- name: Check if OpenShift client file exists
ansible.builtin.stat:
path: "{{ download_dir }}/{{ hostvars[groups[cluster_group][0]].cluster_version }}/{{ hostvars[groups[cluster_group][0]].openshift_client_file }}"
register: openshift_client_file
- name: Download and install OpenShift client package
when: not openshift_client_file.stat.exists
block:
- name: Download OpenShift Client file
become: true
ansible.builtin.get_url:
url: "{{ hostvars[groups[cluster_group][0]].openshift_client_download_url }}"
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
mode: '0644'
- name: Unarchive client file
become: true
ansible.builtin.unarchive:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/openshift-client-linux.tar.gz
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
remote_src: true
- name: Copy client binary
become: true
ansible.builtin.copy:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/oc
dest: /usr/local/bin
remote_src: true
owner: wed
group: wed
mode: '0755'
- name: Check if OpenShift image exists
ansible.builtin.stat:
path: ~/homelab/terraform/{{ cluster_group }}/boot-artifacts/agent.x86_64-initrd.img
register: openshift_image_exists
- name: OpenShift image creation
ansible.builtin.command: /usr/local/bin/openshift-install agent create pxe-files
args:
chdir: ~/homelab/terraform/{{ cluster_group }}
when: not openshift_image_exists.stat.exists
changed_when: true
- name: Create a directory if it does not exist
become: true
ansible.builtin.file:
path: "{{ hostvars[groups['matchbox_server'][0]].assets }}/{{ hostvars[groups[cluster_group][0]].cluster_name }}"
state: directory
owner: matchbox
group: matchbox
mode: '0755'
- name: Copy file with owner and permissions
become: true
ansible.builtin.copy:
src: "{{ ansible_env['HOME'] }}/homelab/terraform/{{ cluster_group }}/boot-artifacts/"
dest: "{{ hostvars[groups['matchbox_server'][0]].assets }}/{{ hostvars[groups[cluster_group][0]].cluster_name }}/"
remote_src: true
owner: matchbox
group: matchbox
mode: '0644'
- name: Verify directory permissions
become: true
ansible.builtin.file:
path: "{{ hostvars[groups['matchbox_server'][0]].assets }}/{{ hostvars[groups[cluster_group][0]].cluster_name }}"
state: directory
owner: matchbox
group: matchbox
mode: '0755'
- name: Create Terraform matchbox groups file from template
ansible.builtin.template:
src: templates/groups.tf.j2
dest: ~/homelab/terraform/{{ cluster_group }}/groups.tf
mode: '0644'
- name: Create Terraform matchbox profiles file from template
ansible.builtin.template:
src: templates/profiles.tf.j2
dest: ~/homelab/terraform/{{ cluster_group }}/profiles.tf
mode: '0644'
- name: Create Terraform matchbox provider file from template
ansible.builtin.template:
src: templates/provider.tf.j2
dest: ~/homelab/terraform/{{ cluster_group }}/provider.tf
mode: '0644'
- name: Configure Matchbox via Terraform
community.general.terraform:
project_path: ~/homelab/terraform/{{ cluster_group }}
state: present
force_init: true

View File

@@ -0,0 +1,218 @@
---
- name: Configure DNS entries for cluster nodes
hosts: internal_cluster
gather_facts: false
become: true
tasks:
- name: Create DNS entry for each cluster node
ansible.builtin.include_tasks: tasks/create_dns_record.yml
vars:
host_ip_address: "{{ ip_address }}"
- name: Configure DNS entries for OpenShift cluster services
hosts: internal_cluster[0]
gather_facts: false
become: true
tasks:
- name: Create DNS entries for OpenShift cluster services
ansible.builtin.include_tasks: tasks/create_dns_record.yml
vars:
dns_name: "{{ item.name }}"
dns_address: "{{ item.address }}"
loop:
- name: "api.{{ cluster_name }}"
address: "{{ api_address }}"
- name: "api-int.{{ cluster_name }}"
address: "{{ api_address }}"
- name: "*.apps.{{ cluster_name }}"
address: "{{ app_address }}"
loop_control:
label: "{{ item.name }}"
- name: Configure DHCP entries for cluster nodes
hosts: internal_cluster
gather_facts: false
become: true
tasks:
- name: Configure DHCP entry for node
ansible.builtin.include_tasks: tasks/configure_dhcp_entry.yml
vars:
host_mac_address: "{{ install_mac_address }}"
host_ip_address: "{{ ip_address }}"
handlers:
- name: Restart dnsmasq
delegate_to: "{{ dhcp_server }}"
become: true
ansible.builtin.service:
name: dnsmasq
state: restarted
- name: Create OpenShift installer files
hosts: matchbox
gather_facts: true
vars:
cluster_group: "internal_cluster"
download_dir: "/var/cache/openshift-install"
tasks:
- name: Remove previous directory
ansible.builtin.file:
path: ~/homelab/terraform/{{ cluster_group }}
state: absent
- name: Create directory
ansible.builtin.file:
path: ~/homelab/terraform/{{ cluster_group }}
state: directory
mode: '0755'
- name: OpenShift Installer install-config.yaml
ansible.builtin.template:
src: templates/install-config.yaml.j2
dest: ~/homelab/terraform/{{ cluster_group }}/install-config.yaml
mode: '0644'
- name: OpenShift Installer agent-config.yaml
ansible.builtin.template:
src: templates/agent-config.yaml.j2
dest: ~/homelab/terraform/{{ cluster_group }}/agent-config.yaml
mode: '0644'
- name: Create directory for OpenShift Installer files
become: true
ansible.builtin.file:
path: "{{ download_dir }}/{{ hostvars[groups[cluster_group][0]].cluster_version }}"
state: directory
mode: '0755'
owner: root
group: root
- name: Check if OpenShift installer file exists
ansible.builtin.stat:
path: "{{ download_dir }}/{{ hostvars[groups[cluster_group][0]].cluster_version }}/{{ hostvars[groups[cluster_group][0]].openshift_installer_file }}"
register: openshift_installer_file
- name: Download and install OpenShift installer package
when: not openshift_installer_file.stat.exists
block:
- name: Download OpenShift Installer file
become: true
ansible.builtin.get_url:
url: "{{ hostvars[groups[cluster_group][0]].openshift_installer_download_url }}"
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
mode: '0644'
- name: Unarchive installer file
become: true
ansible.builtin.unarchive:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/openshift-install-linux.tar.gz
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
remote_src: true
- name: Copy install binary
become: true
ansible.builtin.copy:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/openshift-install
dest: /usr/local/bin
remote_src: true
owner: wed
group: wed
mode: '0755'
- name: Check if OpenShift client file exists
ansible.builtin.stat:
path: "{{ download_dir }}/{{ hostvars[groups[cluster_group][0]].cluster_version }}/{{ hostvars[groups[cluster_group][0]].openshift_client_file }}"
register: openshift_client_file
- name: Download and install OpenShift client package
when: not openshift_client_file.stat.exists
block:
- name: Download OpenShift Client file
become: true
ansible.builtin.get_url:
url: "{{ hostvars[groups[cluster_group][0]].openshift_client_download_url }}"
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
mode: '0644'
- name: Unarchive client file
become: true
ansible.builtin.unarchive:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/openshift-client-linux.tar.gz
dest: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}
remote_src: true
- name: Copy client binary
become: true
ansible.builtin.copy:
src: /var/cache/openshift-install/{{ hostvars[groups[cluster_group][0]].cluster_version }}/oc
dest: /usr/local/bin
remote_src: true
owner: wed
group: wed
mode: '0755'
- name: Check if OpenShift image exists
ansible.builtin.stat:
path: ~/homelab/terraform/{{ cluster_group }}/boot-artifacts/agent.x86_64-initrd.img
register: openshift_image_exists
- name: OpenShift image creation
ansible.builtin.command: /usr/local/bin/openshift-install agent create pxe-files
args:
chdir: ~/homelab/terraform/{{ cluster_group }}
when: not openshift_image_exists.stat.exists
changed_when: true
- name: Create a directory if it does not exist
become: true
ansible.builtin.file:
path: "{{ hostvars[groups['matchbox_server'][0]].assets }}/{{ hostvars[groups[cluster_group][0]].cluster_name }}"
state: directory
owner: matchbox
group: matchbox
mode: '0755'
- name: Copy file with owner and permissions
become: true
ansible.builtin.copy:
src: "{{ ansible_env['HOME'] }}/homelab/terraform/{{ cluster_group }}/boot-artifacts/"
dest: "{{ hostvars[groups['matchbox_server'][0]].assets }}/{{ hostvars[groups[cluster_group][0]].cluster_name }}/"
remote_src: true
owner: matchbox
group: matchbox
mode: '0644'
- name: Verify directory permissions
become: true
ansible.builtin.file:
path: "{{ hostvars[groups['matchbox_server'][0]].assets }}/{{ hostvars[groups[cluster_group][0]].cluster_name }}"
state: directory
owner: matchbox
group: matchbox
mode: '0755'
- name: Create Terraform matchbox groups file from template
ansible.builtin.template:
src: templates/groups.tf.j2
dest: ~/homelab/terraform/{{ cluster_group }}/groups.tf
mode: '0644'
- name: Create Terraform matchbox profiles file from template
ansible.builtin.template:
src: templates/profiles.tf.j2
dest: ~/homelab/terraform/{{ cluster_group }}/profiles.tf
mode: '0644'
- name: Create Terraform matchbox provider file from template
ansible.builtin.template:
src: templates/provider.tf.j2
dest: ~/homelab/terraform/{{ cluster_group }}/provider.tf
mode: '0644'
- name: Configure Matchbox via Terraform
community.general.terraform:
project_path: ~/homelab/terraform/{{ cluster_group }}
state: present
force_init: true

View File

@@ -0,0 +1,16 @@
---
- name: Master playbook to install and configure prometheus
hosts: prometheus_server
become: true
tasks:
- name: Permit traffic in default zone for dns service
firewalld:
port: 9090/tcp
permanent: true
immediate: true
state: enabled
- name: Install unbound via role
ansible.builtin.import_role:
name: prometheus.prometheus.prometheus

View File

@@ -0,0 +1,37 @@
---
- name: Master playbook to install and configure unbound
hosts: unbound_servers
become: true
tasks:
- name: Permit traffic in default zone for dns service
ansible.posix.firewalld:
service: dns
permanent: true
immediate: true
state: enabled
- name: Create the directory
ansible.builtin.file:
path: /etc/systemd/resolved.conf.d
state: directory
mode: '0755'
owner: root
group: root
- name: Put `unbound.conf` in the correct place
ansible.builtin.copy:
src: ../roles/common/files/unbound.conf
dest: /etc/systemd/resolved.conf.d/unbound.conf
mode: '0644'
owner: root
group: root
- name: Restart service systemd-resolved
ansible.builtin.service:
name: systemd-resolved
state: restarted
- name: Install unbound via role
ansible.builtin.import_role:
name: Anthony25.unbound

View File

@@ -0,0 +1,19 @@
---
- name: Master playbook to create VM from a template
hosts: all
gather_facts: false
- name: Proxmox Clone VM Playbook
ansible.builtin.import_playbook: proxmox_clone_vm.yml
- name: DNS Playbook
ansible.builtin.import_playbook: add_dns_entry.yml
- name: DHCP Playbook
ansible.builtin.import_playbook: add_dhcp_entry.yml
- name: Start VM Playbook
ansible.builtin.import_playbook: proxmox_start_vm.yml
- name: Set Hostname Playbook
ansible.builtin.import_playbook: set_hostname.yml

View File

@@ -0,0 +1,16 @@
---
- name: Remove entry from DNS
hosts: all
gather_facts: false
tasks:
- name: Delete DNS entry for {{ inventory_hostname }} #on {{ groups['ipa_servers'][0] }}
delegate_to: "{{ groups['ipaserver'][0] }}"
freeipa.ansible_freeipa.ipadnsrecord:
ipaapi_context: "server"
ipaadmin_password: "{{ vault_freeipa_password }}"
zone_name: "{{ base_domain }}"
records:
- name: "{{ inventory_hostname }}"
del_all: yes
state: absent

View File

@@ -0,0 +1,10 @@
---
- name: Playbook to configure IPA server
hosts: ipaserver
become: true
vars_files:
- idm-vault.yml
roles:
- role: freeipa.ansible_freeipa.ipaserver
state: present

View File

@@ -0,0 +1,15 @@
- name: Install Observability stack (targets)
hosts: target
tags:
- monitoring
- target
roles:
- ../roles/target
- name: Install Observability stack (observer)
hosts: observer
tags:
- monitoring
- observer
roles:
- ../roles/observer

View File

@@ -0,0 +1,37 @@
---
- name: Create VM ID from IP address for Proxmox hosts
hosts: all
gather_facts: false
tasks:
- name: Create Proxmox VMs
delegate_to: "localhost"
when: platform is defined and platform == "proxmox"
block:
- name: Create VM ID from IP address
ansible.builtin.set_fact:
vm_id: "{{ ip_address.split('.')[-2] }}{{ '%03d' % (ip_address.split('.')[-1] | int) }}"
- name: Clone VM with source vmid and target newid and raw format
community.proxmox.proxmox_kvm:
api_user: "{{ proxmox_user }}"
api_password: "{{ proxmox_password }}"
api_host: "{{ proxmox_host }}"
clone: "{{ vm_clone_source }}"
newid: "{{ vm_id }}"
name: "{{ inventory_hostname }}"
node: "{{ proxmox_clone_node }}"
storage: "{{ vm_storage }}"
format: raw
timeout: 600
# - name: Add VM to HA group
# community.proxmox.proxmox_cluster_ha_resources:
# api_user: "{{ proxmox_user }}"
# api_password: "{{ proxmox_password }}"
# api_host: "{{ proxmox_host }}"
# name: vm:"{{ vm_id }}"
# state: "present"
# group: "{{ ha_group }}"
# max_relocate: 2
# max_restart: 2

View File

@@ -0,0 +1,32 @@
---
- name: Create VM ID from IP address for Proxmox hosts
hosts: all
gather_facts: false
tasks:
- name: Start Proxmox VM
delegate_to: "localhost"
when: platform is defined and platform == "proxmox"
community.proxmox.proxmox_kvm:
api_user: "{{ proxmox_user }}"
api_password: "{{ proxmox_password }}"
api_host: "{{ proxmox_host }}"
name: "{{ inventory_hostname }}"
node: "{{ proxmox_clone_node }}"
state: started
# - name: Wait for the VM to start
# delegate_to: "localhost"
# wait_for:
# port: 22
# host: "{{ inventory_hostname }}"
# search_regex: OpenSSH
# delay: 10
# timeout: 60
# - name: Wait for the reboot to complete if there was a change.
# wait_for_connection:
# connect_timeout: 10
# sleep: 5
# delay: 5
# timeout: 300

View File

@@ -0,0 +1,11 @@
---
- name: Set hostname of VM
hosts: all
gather_facts: false
tasks:
- name: Set hostname of VM
become: true
delegate_to: "{{ inventory_hostname }}"
ansible.builtin.hostname:
name: "{{ hostname }}"

View File

@@ -0,0 +1,10 @@
---
- name: Add DHCP entry for {{ inventory_hostname }}
delegate_to: "{{ dhcp_server }}"
become: true
ansible.builtin.lineinfile:
path: /etc/dnsmasq.d/hosts.conf
regexp: "# {{ inventory_hostname }}$"
line: "dhcp-host={{ host_mac_address | lower }},{{ host_ip_address }} # {{ inventory_hostname }}"
state: present
notify: Restart dnsmasq

View File

@@ -0,0 +1,11 @@
---
- name: "Create DNS record for {{ dns_name | default(inventory_hostname) }}"
delegate_to: "{{ dns_server }}"
freeipa.ansible_freeipa.ipadnsrecord:
ipaapi_context: "server"
ipaadmin_password: "{{ vault_freeipa_password }}"
name: "{{ dns_name | default(inventory_hostname) }}"
zone_name: "{{ base_domain }}"
record_type: "A"
record_value: "{{ dns_address | default(host_ip_address) }}"
record_ttl: 60

View File

@@ -0,0 +1,40 @@
apiVersion: v1alpha1
kind: AgentConfig
metadata:
name: {{ hostvars[groups[cluster_group][0]].cluster_name }}
rendezvousIP: {{ hostvars[groups[cluster_group][0]].ip_address }}
bootArtifactsBaseURL: {{ hostvars[groups['matchbox_server'][0]].http_endpoint }}/assets/hub/
hosts:
{% for host in groups[cluster_group] %}
- hostname: {{ host }}
role: {{ hostvars[host].node_role | default('master') }}
interfaces:
- name: {{ hostvars[host].primary_interface }}
macAddress: {{ hostvars[host].install_mac_address }}
networkConfig:
interfaces:
- name: {{ hostvars[host].primary_interface }}
type: ethernet
state: up
identifier: mac-address
mac-address: {{ hostvars[host].install_mac_address }}
ipv4:
enabled: true
dhcp: true
- name: {{ hostvars[host].boot_interface }}
type: ethernet
state: down
identifier: mac-address
mac-address: {{ hostvars[host].boot_mac_address }}
dns-resolver:
config:
server:
- 10.1.71.251
- 10.1.71.252
routes:
config:
- destination: 0.0.0.0/0
next-hop-address: 10.1.71.1
next-hop-interface: {{ hostvars[host].primary_interface }}
table-id: 254
{% endfor %}

View File

@@ -0,0 +1,14 @@
// Matcher group for OCP Internal machines
{% for host in groups[cluster_group] %}
resource "matchbox_group" "{{ host }}" {
name = "{{ host }}" # Physical Server
profile = matchbox_profile.openshift-agent-install.name
selector = {
{% if hostvars[host].boot_mac_address == hostvars[host].install_mac_address %}
mac = "{{ hostvars[host].boot_mac_address }}" # PXE boots and installs to same NIC
{% else %}
mac = "{{ hostvars[host].boot_mac_address }}" # PXE boots to 1GbE NIC, installs to 10GbE NIC
{% endif %}
}
}
{% endfor %}

View File

@@ -0,0 +1,28 @@
apiVersion: v1
baseDomain: {{ hostvars[groups[cluster_group][0]].base_domain }}
compute:
- name: worker
hyperthreading: Enabled
replicas: {{ hostvars[groups[cluster_group][0]].worker_node_count }}
controlPlane:
hyperthreading: Enabled
name: master
replicas: {{ hostvars[groups[cluster_group][0]].master_node_count }}
metadata:
name: {{ hostvars[groups[cluster_group][0]].cluster_name }}
networking:
clusterNetwork:
- cidr: {{ hostvars[groups[cluster_group][0]].cluster_network }}
hostPrefix: {{ hostvars[groups[cluster_group][0]].cluster_network_host_prefix }}
machineNetwork:
- cidr: {{ hostvars[groups[cluster_group][0]].machine_network }}
networkType: OVNKubernetes
serviceNetwork:
- {{ hostvars[groups[cluster_group][0]].service_network }}
platform:
{{ hostvars[groups[cluster_group][0]].platform_type }}:
apiVIP: {{ hostvars[groups[cluster_group][0]].api_address }}
ingressVIP: {{ hostvars[groups[cluster_group][0]].app_address }}
fips: false
pullSecret: '{{ vault_pull_secret }}'
sshKey: '{{ vault_ssh_key }}'

View File

@@ -0,0 +1,16 @@
// Fedora CoreOS profile
resource "matchbox_profile" "openshift-agent-install" {
name = "{{ hostvars[groups[cluster_group][0]].cluster_name }}"
kernel = "/assets/{{ hostvars[groups[cluster_group][0]].cluster_name }}/agent.x86_64-vmlinuz"
initrd = [
"--name initrd /assets/{{ hostvars[groups[cluster_group][0]].cluster_name }}/agent.x86_64-initrd.img"
]
args = [
"initrd=initrd",
"coreos.live.rootfs_url={{ hostvars[groups['matchbox_server'][0]].http_endpoint }}/assets/{{ hostvars[groups[cluster_group][0]].cluster_name }}/agent.x86_64-rootfs.img",
"rw",
"ignition.firstboot",
"ignition.platform.id=metal",
]
}

View File

@@ -0,0 +1,20 @@
// Configure the matchbox provider
provider "matchbox" {
endpoint = "{{ hostvars[groups['matchbox_server'][0]].rpc_endpoint }}"
client_cert = file("/etc/matchbox/client.crt")
client_key = file("/etc/matchbox/client.key")
ca = file("/etc/matchbox/ca.crt")
}
terraform {
required_providers {
ct = {
source = "poseidon/ct"
version = "0.13.0"
}
matchbox = {
source = "poseidon/matchbox"
version = "0.5.4"
}
}
}

View File

@@ -0,0 +1,121 @@
---
- name: Linux OS Upgrade
hosts: all
gather_facts: true
become: true
tasks:
- name: Update all packages
ansible.builtin.package:
name: '*'
state: latest
update_cache: true
- name: Upgrade Debian and Ubuntu systems with apt
when: ansible_os_family == "Debian"
block:
- name: Dist-upgrade
ansible.builtin.apt:
upgrade: dist
update_cache: true
register: upgrade_result
- name: Debain check if reboot is required
ansible.builtin.shell: "[ -f /var/run/reboot-required ]"
failed_when: false
register: debian_reboot_required
changed_when: debian_reboot_required.rc == 0
notify:
- Reboot server
- name: Debian remove unneeded dependencies
ansible.builtin.apt:
autoremove: true
register: autoremove_result
- name: Debian print errors if upgrade failed
ansible.builtin.debug:
msg: |
Upgrade Result: {{ upgrade_result }}
Autoremove Result: {{ autoremove_result }}
- name: Upgrade RHEL systems with DNF
when: ansible_os_family == "RedHat" and not (ansible_distribution_major_version == "7")
block:
- name: Get packages that can be upgraded with DNF
ansible.builtin.dnf:
list: upgrades
state: latest
update_cache: true
register: reg_dnf_output_all
- name: List packages that can be upgraded with DNF
ansible.builtin.debug:
msg: "{{ reg_dnf_output_all.results | map(attribute='name') | list }}"
- name: Upgrade packages with DNF
become: true
ansible.builtin.dnf:
name: '*'
state: latest
update_cache: true
update_only: false
register: reg_upgrade_ok
- name: Print DNF errors if upgrade failed
ansible.builtin.debug:
msg: "Packages upgrade failed"
when: reg_upgrade_ok is not defined
- name: Install dnf-utils
when: reg_dnf_output_all is defined
become: true
ansible.builtin.dnf:
name: 'dnf-utils'
state: latest
update_cache: true
- name: Upgrade legacy RHEL systems with YUM
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7"
block:
- name: Get packages that can be upgraded with YUM
ansible.builtin.yum:
list: upgrades
state: latest
update_cache: true
register: reg_yum_output_all
- name: List packages that can be upgraded with YUM
ansible.builtin.debug:
msg: "{{ reg_yum_output_all.results | map(attribute='name') | list }}"
- name: Upgrade packages with YUM
become: true
ansible.builtin.yum:
name: '*'
state: latest
update_cache: true
update_only: false
register: reg_yum_upgrade_ok
- name: Print YUM errors if upgrade failed
ansible.builtin.debug:
msg: "Packages upgrade failed"
when: reg_yum_upgrade_ok is not defined
- name: Check legacy RHEL system if a reboot is required
become: true
ansible.builtin.command: needs-restarting -r
register: reg_reboot_required
ignore_errors: true
failed_when: false
changed_when: reg_reboot_required.rc != 0
notify:
- Reboot server
handlers:
- name: Reboot server
ansible.builtin.reboot:
msg: "Reboot initiated by Ansible after OS update"
reboot_timeout: 3600
test_command: uptime

View File

@@ -0,0 +1,4 @@
[Resolve]
DNS=127.0.0.1
DNSSEC=yes
DNSStubListener=no

View File

@@ -0,0 +1,11 @@
---
prometheus_version: v2.40.1
grafana_version: "9.2.5"
alertmanager_version: v0.24.0
#alertmanager_smtp_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
64306663363562356132323065396635636630373031303739323666373262663961393132316333
6135653763363566303331313639633030623530646239310a353236343035643132646230333466
36336439376131333630346563323833313164353265313264643232373465633561663331396133
3163303166373166390a396131303239356139653063616437363933333130393563646338663933
3966

View File

@@ -0,0 +1,8 @@
apiVersion: 1
providers:
- name: Pre-loaded local dashboards
type: file
options:
foldersFromFilesStructure: true
path: /var/lib/grafana/dashboards

View File

@@ -0,0 +1,814 @@
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "Prometheus as the datasource is obligatory",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "7.4.5"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": 14282,
"graphTooltip": 0,
"id": null,
"iteration": 1617715580880,
"links": [],
"panels": [
{
"collapsed": false,
"datasource": "Prometheus",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 8,
"panels": [],
"title": "CPU",
"type": "row"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 1
},
"hiddenSeries": false,
"id": 15,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null as zero",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.4.5",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"expr": "sum(rate(container_cpu_usage_seconds_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name) *100",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "CPU Usage",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"$$hashKey": "object:606",
"format": "percent",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"$$hashKey": "object:607",
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"collapsed": false,
"datasource": "Prometheus",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 8
},
"id": 11,
"panels": [],
"title": "Memory",
"type": "row"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 9
},
"hiddenSeries": false,
"id": 9,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null as zero",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.4.5",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"expr": "sum(container_memory_rss{instance=~\"$host\",name=~\"$container\",name=~\".+\"}) by (name)",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Memory Usage",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"$$hashKey": "object:606",
"format": "bytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"$$hashKey": "object:607",
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 9
},
"hiddenSeries": false,
"id": 14,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null as zero",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.4.5",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"expr": "sum(container_memory_cache{instance=~\"$host\",name=~\"$container\",name=~\".+\"}) by (name)",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Memory Cached",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"$$hashKey": "object:606",
"format": "bytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"$$hashKey": "object:607",
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"collapsed": false,
"datasource": "Prometheus",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 17
},
"id": 2,
"panels": [],
"title": "Network",
"type": "row"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 18
},
"hiddenSeries": false,
"id": 4,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"hideEmpty": false,
"hideZero": false,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"sideWidth": null,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.4.5",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(rate(container_network_receive_bytes_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name)",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Received Network Traffic",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"$$hashKey": "object:674",
"format": "Bps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"$$hashKey": "object:675",
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 18
},
"hiddenSeries": false,
"id": 6,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.4.5",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(rate(container_network_transmit_bytes_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name)",
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Sent Network Traffic",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"$$hashKey": "object:832",
"format": "Bps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"$$hashKey": "object:833",
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"collapsed": false,
"datasource": "Prometheus",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 26
},
"id": 19,
"panels": [],
"title": "Misc",
"type": "row"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"custom": {
"align": null,
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "id"
},
"properties": [
{
"id": "custom.width",
"value": 260
}
]
},
{
"matcher": {
"id": "byName",
"options": "Running"
},
"properties": [
{
"id": "unit",
"value": "d"
},
{
"id": "decimals",
"value": 1
},
{
"id": "custom.displayMode",
"value": "color-text"
},
{
"id": "color",
"value": {
"fixedColor": "dark-green",
"mode": "fixed"
}
}
]
}
]
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 27
},
"id": 17,
"options": {
"showHeader": true,
"sortBy": []
},
"pluginVersion": "7.4.5",
"targets": [
{
"expr": "(time() - container_start_time_seconds{instance=~\"$host\",name=~\"$container\",name=~\".+\"})/86400",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Containers Info",
"transformations": [
{
"id": "filterFieldsByName",
"options": {
"include": {
"names": [
"container_label_com_docker_compose_project",
"container_label_com_docker_compose_project_working_dir",
"image",
"instance",
"name",
"Value",
"container_label_com_docker_compose_service"
]
}
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Value": "Running",
"container_label_com_docker_compose_project": "Label",
"container_label_com_docker_compose_project_working_dir": "Working dir",
"container_label_com_docker_compose_service": "Service",
"image": "Registry Image",
"instance": "Instance",
"name": "Name"
}
}
}
],
"type": "table"
}
],
"schemaVersion": 27,
"style": "dark",
"tags": ["cadvisor", "docker"],
"templating": {
"list": [
{
"allValue": ".*",
"current": {},
"datasource": "Prometheus",
"definition": "label_values({__name__=~\"container.*\"},instance)",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": "Host",
"multi": false,
"name": "host",
"options": [],
"query": {
"query": "label_values({__name__=~\"container.*\"},instance)",
"refId": "Prometheus-host-Variable-Query"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 5,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"allValue": ".*",
"current": {},
"datasource": "Prometheus",
"definition": "label_values({__name__=~\"container.*\", instance=~\"$host\"},name)",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": "Container",
"multi": false,
"name": "container",
"options": [],
"query": {
"query": "label_values({__name__=~\"container.*\", instance=~\"$host\"},name)",
"refId": "Prometheus-container-Variable-Query"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Cadvisor exporter",
"uid": "pMEd7m0Mz",
"version": 1,
"description": "Simple exporter for cadvisor only"
}

View File

@@ -0,0 +1,7 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://192.168.0.1:9090

View File

@@ -0,0 +1,11 @@
groups:
- name: AllInstances
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
annotations:
title: 'Instance {{ $labels.instance }} down'
description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minute.'
labels:
severity: 'critical'

View File

@@ -0,0 +1,28 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: prometheus
scrape_interval: 30s
static_configs:
- targets: ["localhost:9090"]
- job_name: node-exporter
scrape_interval: 30s
static_configs:
- targets:
["192.168.0.1:9100", "192.168.0.10:9100", "192.168.0.11:9100"]
- job_name: cadvisor
scrape_interval: 30s
static_configs:
- targets: ["192.168.0.1:9101", "192.168.0.11:9101"]
rule_files:
- prometheus_alerts_rules.yml
alerting:
alertmanagers:
- static_configs:
- targets:
- 192.168.0.1:9093

View File

@@ -0,0 +1,85 @@
- name: Create Folder /srv/prometheus if not exist
file:
path: /srv/prometheus
mode: 0755
state: directory
- name: Create Folder /srv/grafana if not exist
file:
path: /srv/grafana
mode: 0755
state: directory
- name: Create Folder /srv/alertmanager if not exist
file:
path: /srv/alertmanager
mode: 0755
state: directory
- name: Create prometheus configuration file
copy:
dest: /srv/prometheus/prometheus.yml
src: prometheus_main.yml
mode: 0644
- name: Create prometheus alert configuration file
copy:
dest: /srv/prometheus/prometheus_alerts_rules.yml
src: prometheus_alerts_rules.yml
mode: 0644
- name: Create grafana configuration files
copy:
dest: /srv/
src: grafana
mode: 0644
- name: Create alertmanager configuration file
template:
dest: /srv/alertmanager/alertmanager.yml
src: alertmanager/alertmanager.j2
mode: 0644
- name: Create Prometheus container
docker_container:
name: prometheus
restart_policy: always
image: prom/prometheus:
volumes:
- /srv/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /srv/prometheus/prometheus_alerts_rules.yml:/etc/prometheus/prometheus_alerts_rules.yml
- prometheus_main_data:/prometheus
command: >
--config.file=/etc/prometheus/prometheus.yml
--storage.tsdb.path=/prometheus
--web.console.libraries=/etc/prometheus/console_libraries
--web.console.templates=/etc/prometheus/consoles
--web.enable-lifecycle
published_ports: "9090:9090"
- name: Create Grafana container
docker_container:
name: grafana
restart_policy: always
image: grafana/grafana:
volumes:
- grafana-data:/var/lib/grafana
- /srv/grafana/provisioning:/etc/grafana/provisioning
- /srv/grafana/dashboards:/var/lib/grafana/dashboards
env:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
published_ports: "3000:3000"
- name: Create Alertmanager container
docker_container:
name: alertmanager
restart_policy: always
image: prom/alertmanager:
volumes:
- alertmanager-data:/data
- /srv/alertmanager:/config
command: >
--config.file=/config/alertmanager.yml
--log.level=debug
published_ports: "9093:9093"

View File

@@ -0,0 +1,13 @@
route:
receiver: "mail"
repeat_interval: 4h
group_by: [ alertname ]
receivers:
- name: "mail"
email_configs:
- smarthost: "outlook.office365.com:587"
auth_username: "test@padok.fr"
auth_password: "{{ alertmanager_smtp_password }}"
from: "test@padok.fr"
to: "test@padok.fr"

View File

@@ -0,0 +1,13 @@
# requirements.yml
collections:
- name: community.general
version: 11.1.0
- name: nccurry.openshift
version: 1.4.0
- name: somaz94.ansible_k8s_iac_tool
version: 1.1.6
- name: prometheus.prometheus
version: 0.27.0

View File

@@ -0,0 +1,3 @@
---
node_exporter_version: v1.4.0
cadvisor_version: v0.46.0

View File

@@ -0,0 +1,29 @@
---
- name: Create NodeExporter
docker_container:
name: node-exporter
restart_policy: always
image: prom/node-exporter:{{ node_exporter_version }}
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command: >
--path.procfs=/host/proc
--path.rootfs=/rootfs
--path.sysfs=/host/sys
--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)
published_ports: "9100:9100"
- name: Create cAdvisor
docker_container:
name: cadvisor
restart_policy: always
image: gcr.io/cadvisor/cadvisor:{{ cadvisor_version }}
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
published_ports: "9101:8080"

View 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 = [
"{{ ip_address }}",
]
ttl = 60
}

View File

@@ -0,0 +1,32 @@
# Configure the DNS Provider
provider "freeipa" {
host = var.freeipa_server
username = var.freeipa_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"
}
}
}