Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 06fd10e

Browse files
committed
lots o changes for A2
1 parent ebab304 commit 06fd10e

File tree

74 files changed

+1464
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1464
-100
lines changed

.DS_Store

10 KB
Binary file not shown.

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

05-a2-forwarder.conf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
filter {
2+
ruby {
3+
init => "
4+
require 'net/http'
5+
require 'uri'
6+
require 'json'
7+
require 'openssl'
8+
"
9+
code => "
10+
automate_url = 'https://automate2.lab.local/data-collector/v0'
11+
automate_token = '9nPsVHKuVw6qVkxJYuTJBjNSO6g='
12+
#Max size of rabbitmq queues in bytes, if exceeded stop sending data to a2
13+
rabbit_max_queue = 1000000 #1GB
14+
uri = URI.parse(automate_url)
15+
16+
# Verify Automate ingest is not backed up
17+
queue_size = `du -s /var/opt/delivery/rabbitmq/db/`.split.first.to_i
18+
if (queue_size > rabbit_max_queue) then
19+
puts %{queue_size: #{queue_size} exceeds rabbit_max_queue: #{rabbit_max_queue} disabling a2 forwarding}
20+
else
21+
# Create the HTTP objects
22+
http = Net::HTTP.new(uri.host, uri.port)
23+
http.use_ssl = true
24+
http.open_timeout = 5
25+
http.read_timeout = 10
26+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
27+
headers = {'X-Data-Collector-Token'=> automate_token, 'X-Data-Collector-Auth'=> 'version=1.0', 'Content-Type'=> 'application/json'}
28+
request = Net::HTTP::Post.new(uri.request_uri, headers)
29+
request.body = event.to_json
30+
31+
# Send the request
32+
response = http.request(request)
33+
puts %{#{response.body}\n#{response.code}} unless response.code.match(/2[0-9]{2}/)
34+
end
35+
"
36+
}
37+
}

Automate2Server.tf

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#create a public IP address for the virtual machine
2+
resource "azurerm_public_ip" "automate2_pubip" {
3+
name = "automate2_pubip"
4+
location = "${var.azure_region}"
5+
resource_group_name = "${azurerm_resource_group.rg.name}"
6+
public_ip_address_allocation = "dynamic"
7+
domain_name_label = "${var.automate2_server_name}"
8+
9+
tags {
10+
environment = "${var.azure_env}"
11+
}
12+
}
13+
14+
#create the network interface and put it on the proper vlan/subnet
15+
resource "azurerm_network_interface" "automate2_ip" {
16+
name = "automate2_ip"
17+
location = "${var.azure_region}"
18+
resource_group_name = "${azurerm_resource_group.rg.name}"
19+
20+
ip_configuration {
21+
name = "automate2_ipconf"
22+
subnet_id = "${azurerm_subnet.subnet.id}"
23+
private_ip_address_allocation = "static"
24+
private_ip_address = "10.1.1.12"
25+
public_ip_address_id = "${azurerm_public_ip.automate2_pubip.id}"
26+
}
27+
}
28+
29+
#create the actual VM
30+
resource "azurerm_virtual_machine" "automate2" {
31+
name = "automate2"
32+
location = "${var.azure_region}"
33+
resource_group_name = "${azurerm_resource_group.rg.name}"
34+
network_interface_ids = ["${azurerm_network_interface.automate2_ip.id}"]
35+
vm_size = "${var.automate_vm_size}"
36+
depends_on = ["azurerm_virtual_machine.automate"]
37+
38+
storage_image_reference {
39+
publisher = "Canonical"
40+
offer = "UbuntuServer"
41+
sku = "16.04-LTS"
42+
version = "latest"
43+
}
44+
45+
storage_os_disk {
46+
name = "automate2_osdisk1"
47+
caching = "ReadWrite"
48+
create_option = "FromImage"
49+
managed_disk_type = "Standard_LRS"
50+
}
51+
52+
os_profile {
53+
computer_name = "${var.automate2_server_name}"
54+
admin_username = "${var.username}"
55+
admin_password = "${var.password}"
56+
}
57+
58+
os_profile_linux_config {
59+
disable_password_authentication = false
60+
}
61+
62+
tags {
63+
environment = "${var.azure_env}"
64+
}
65+
66+
connection {
67+
host = "${azurerm_public_ip.automate2_pubip.fqdn}"
68+
type = "ssh"
69+
user = "${var.username}"
70+
password = "${var.password}"
71+
}
72+
73+
provisioner "file" {
74+
source = "labadmin"
75+
destination = "/home/labadmin/.ssh/id_rsa"
76+
}
77+
78+
provisioner "file" {
79+
source = "labadmin.pub"
80+
destination = "/home/labadmin/.ssh/authorized_keys"
81+
}
82+
83+
provisioner "file" {
84+
source = "InstallChefAutomate2.sh"
85+
destination = "/tmp/InstallChefAutomate2.sh"
86+
}
87+
88+
provisioner "file" {
89+
source = "config.toml"
90+
destination = "/tmp/config.toml"
91+
}
92+
93+
provisioner "remote-exec" {
94+
inline = [
95+
"sudo chmod +x /tmp/InstallChefAutomate2.sh",
96+
"sudo /tmp/InstallChefAutomate2.sh ${var.automate_server_name} ${var.chef_server_name} ${var.automate2_server_name}",
97+
]
98+
}
99+
}
100+
101+
# output "aip" {
102+
# value = "${azurerm_public_ip.automate_pubip.ip_address}"
103+
# }
104+
105+
output "a2fqdn" {
106+
value = "${azurerm_public_ip.automate2_pubip.fqdn}"
107+
}

AutomateServer.tf

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ resource "azurerm_network_interface" "automate_ip" {
2020
ip_configuration {
2121
name = "automate_ipconf"
2222
subnet_id = "${azurerm_subnet.subnet.id}"
23-
private_ip_address_allocation = "dynamic"
23+
private_ip_address_allocation = "static"
24+
private_ip_address = "10.1.1.11"
2425
public_ip_address_id = "${azurerm_public_ip.automate_pubip.id}"
2526
}
2627
}
@@ -32,6 +33,7 @@ resource "azurerm_virtual_machine" "automate" {
3233
resource_group_name = "${azurerm_resource_group.rg.name}"
3334
network_interface_ids = ["${azurerm_network_interface.automate_ip.id}"]
3435
vm_size = "${var.automate_vm_size}"
36+
depends_on = ["azurerm_virtual_machine.chef"]
3537

3638
storage_image_reference {
3739
publisher = "Canonical"
@@ -59,7 +61,6 @@ resource "azurerm_virtual_machine" "automate" {
5961

6062
tags {
6163
environment = "${var.azure_env}"
62-
6364
}
6465

6566
connection {
@@ -85,14 +86,24 @@ resource "azurerm_virtual_machine" "automate" {
8586
}
8687

8788
provisioner "file" {
88-
source = "delivery.license"
89-
destination = "/tmp/delivery.license"
89+
source = "automate.license"
90+
destination = "/tmp/automate.license"
91+
}
92+
93+
provisioner "file" {
94+
source = "05-a2-forwarder.conf"
95+
destination = "/tmp/05-a2-forwarder.conf"
96+
}
97+
98+
provisioner "file" {
99+
source = "profiles/"
100+
destination = "/tmp"
90101
}
91102

92103
provisioner "remote-exec" {
93104
inline = [
94105
"sudo chmod +x /tmp/InstallChefAutomate.sh",
95-
"sudo /tmp/InstallChefAutomate.sh -a ${var.automate_server_name} -c ${var.chef_server_name} -d ${var.chef_server_user} -e ${var.chef_server_org_shortname} -v ${var.automate_server_version} -u ${var.automate_server_user} -p ${var.automate_server_user_password} -z ${var.azure_region}",
106+
"sudo /tmp/InstallChefAutomate.sh ${var.automate_server_name} ${var.chef_server_name} ${var.chef_server_user} ${var.chef_server_org_shortname} ${var.automate_server_version} ${var.automate_server_user} ${var.automate_server_user_password} ${var.azure_region} ${var.username} ${var.inspec_version} > install.log",
96107
]
97108
}
98109
}
@@ -103,4 +114,4 @@ resource "azurerm_virtual_machine" "automate" {
103114

104115
output "afqdn" {
105116
value = "${azurerm_public_ip.automate_pubip.fqdn}"
106-
}
117+
}

AzureCredentials.tf.template

Lines changed: 0 additions & 7 deletions
This file was deleted.

ChefNodes.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#create a public IP address for the virtual machine
22
resource "azurerm_public_ip" "node_pubip" {
3-
count = "${var.chef_node_count}"
3+
count = "${var.chef_node_count}"
44
name = "node${count.index}_pubip"
55
location = "${var.azure_region}"
66
resource_group_name = "${azurerm_resource_group.rg.name}"
77
public_ip_address_allocation = "dynamic"
8-
domain_name_label = "jm-tr-node${count.index}"
8+
domain_name_label = "jm-node${count.index}"
99

1010
tags {
1111
environment = "${var.azure_env}"
@@ -14,7 +14,7 @@ resource "azurerm_public_ip" "node_pubip" {
1414

1515
#create the network interface and put it on the proper vlan/subnet
1616
resource "azurerm_network_interface" "node_ip" {
17-
count = "${var.chef_node_count}"
17+
count = "${var.chef_node_count}"
1818
name = "node${count.index}_ip"
1919
location = "${var.azure_region}"
2020
resource_group_name = "${azurerm_resource_group.rg.name}"
@@ -23,18 +23,20 @@ resource "azurerm_network_interface" "node_ip" {
2323
name = "node${count.index}_ipconf"
2424
subnet_id = "${azurerm_subnet.subnet.id}"
2525
private_ip_address_allocation = "dynamic"
26+
2627
# public_ip_address_id = ["${element(azurerm_public_ip.node_pubip.*.id, count.index)}"]
2728
}
2829
}
2930

3031
#create the actual VM
3132
resource "azurerm_virtual_machine" "node" {
32-
count = "${var.chef_node_count}"
33+
count = "${var.chef_node_count}"
3334
name = "node${count.index}"
3435
location = "${var.azure_region}"
3536
resource_group_name = "${azurerm_resource_group.rg.name}"
3637
network_interface_ids = ["${element(azurerm_network_interface.node_ip.*.id, count.index)}"]
3738
vm_size = "${var.chef_node_vm_size}"
39+
depends_on = ["azurerm_virtual_machine.automate2"]
3840

3941
storage_image_reference {
4042
publisher = "Canonical"
@@ -65,7 +67,7 @@ resource "azurerm_virtual_machine" "node" {
6567
}
6668

6769
# connection {
68-
70+
6971
# host = ["${element(azurerm_public_ip.node.*._pubip.fqdn, count.index)}"]
7072
# type = "ssh"
7173
# user = "${var.username}"
@@ -81,9 +83,9 @@ resource "azurerm_virtual_machine" "node" {
8183
# source = "labadmin.pub"
8284
# destination = "/home/labadmin/.ssh/authorized_keys"
8385
# }
84-
8586
}
8687

8788
# output "node${count.index}fqdn" {
8889
# value = ["${element(azurerm_public_ip.node.*._pubip.fqdn, count.index)}"]
89-
# }
90+
# }
91+

ChefServer.tf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ resource "azurerm_network_interface" "chef_ip" {
1818
resource_group_name = "${azurerm_resource_group.rg.name}"
1919

2020
ip_configuration {
21-
name = "chef_ipconf"
22-
subnet_id = "${azurerm_subnet.subnet.id}"
23-
private_ip_address_allocation = "dynamic"
21+
name = "chef_ipconf"
22+
subnet_id = "${azurerm_subnet.subnet.id}"
23+
24+
# private_ip_address_allocation = "dynamic"
25+
private_ip_address_allocation = "static"
26+
private_ip_address = "10.1.1.10" # "${cidrhost(10.1.1.0/24, 10)}"
2427
public_ip_address_id = "${azurerm_public_ip.chef_pubip.id}"
2528
}
2629
}
@@ -86,7 +89,7 @@ resource "azurerm_virtual_machine" "chef" {
8689
provisioner "remote-exec" {
8790
inline = [
8891
"sudo chmod +x /tmp/InstallChefServer.sh",
89-
"sudo /tmp/InstallChefServer.sh -a ${var.automate_server_name} -z ${var.azure_region} -c ${var.chef_server_name} -v ${var.chef_server_version} -u ${var.chef_server_user} -p ${var.chef_server_user_password} -n ${var.chef_server_user_firstname} -l ${var.chef_server_user_lastname} -e ${var.chef_server_user_email} -s ${var.chef_server_org_shortname} -f ${var.chef_server_org_fullname} -j ${var.chef_server_install_pushjobs} -h ${var.chef_server_pushjobs_version} -m ${var.chef_server_install_manage} -g ${var.chef_server_manage_version} > install.log ",
92+
"sudo /tmp/InstallChefServer.sh ${var.automate_server_name} ${var.azure_region} ${var.chef_server_name} ${var.chef_server_version} ${var.chef_server_user} ${var.chef_server_user_password} ${var.chef_server_user_firstname} ${var.chef_server_user_lastname} ${var.chef_server_user_email} ${var.chef_server_org_shortname} '${var.chef_server_org_fullname}' ${var.chef_server_install_pushjobs} ${var.chef_server_pushjobs_version} ${var.chef_server_install_manage} ${var.chef_server_manage_version} ${var.chefdk_version} > install.log ",
9093
]
9194
}
9295
}
@@ -97,4 +100,4 @@ resource "azurerm_virtual_machine" "chef" {
97100

98101
output "cfqdn" {
99102
value = "${azurerm_public_ip.chef_pubip.fqdn}"
100-
}
103+
}

ChefServer2.tf renamed to ChefServer2.tf.temp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resource "azurerm_public_ip" "chef2_pubip" {
44
location = "${var.azure_region}"
55
resource_group_name = "${azurerm_resource_group.rg.name}"
66
public_ip_address_allocation = "dynamic"
7-
domain_name_label = "jm-tr-chef2"
7+
domain_name_label = "jm-chef2"
88

99
tags {
1010
environment = "${var.azure_env}"
@@ -97,4 +97,4 @@ resource "azurerm_virtual_machine" "chef2" {
9797

9898
output "c2fqdn" {
9999
value = "${azurerm_public_ip.chef2_pubip.fqdn}"
100-
}
100+
}

0 commit comments

Comments
 (0)