provider/cobbler: acc tests TF and script tweaks
This commit is contained in:
parent
c0c17ba1d2
commit
17e50328eb
|
@ -1,10 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
# This script assumes Ubuntu 14.04 is being used.
|
# This script assumes Ubuntu 14.04 is being used.
|
||||||
# It will create a standard Cobbler environment that can be used for acceptance testing.
|
# It will create a standard Cobbler environment that can be used for acceptance testing.
|
||||||
|
|
||||||
|
# With this enviornment spun up, the config should be:
|
||||||
|
# COBBLER_URL=http://127.0.0.1:25151
|
||||||
|
# COBBLER_USERNAME=cobbler
|
||||||
|
# COBBLER_PASSWORD=cobbler
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y git make mercurial
|
sudo apt-get install -y build-essential git mercurial
|
||||||
|
|
||||||
cd
|
cd
|
||||||
echo 'export PATH=$PATH:$HOME/terraform:$HOME/go/bin' >> ~/.bashrc
|
echo 'export PATH=$PATH:$HOME/terraform:$HOME/go/bin' >> ~/.bashrc
|
||||||
|
@ -63,8 +70,9 @@ sudo sed -i -e 's/^manage_dns: 0/manage_dns: 1/' /etc/cobbler/settings
|
||||||
sudo sed -i -e 's/^next_server:.*/next_server: 127.0.0.1/' /etc/cobbler/settings
|
sudo sed -i -e 's/^next_server:.*/next_server: 127.0.0.1/' /etc/cobbler/settings
|
||||||
sudo sed -i -e 's/^server:.*/server: 127.0.0.1/' /etc/cobbler/settings
|
sudo sed -i -e 's/^server:.*/server: 127.0.0.1/' /etc/cobbler/settings
|
||||||
|
|
||||||
sudo tee /etc/cobbler/users.digets <<EOF
|
# User: cobbler / Pass: cobbler
|
||||||
cobbler:Cobbler:8e9c0aa3ae45bb39347866c41cb4d293
|
sudo tee /etc/cobbler/users.digest <<EOF
|
||||||
|
cobbler:Cobbler:2d6bae81669d707b72c0bd9806e01f3
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# The stock version of Cobbler in the Ubuntu repository still has the old cobbler homepage URL
|
# The stock version of Cobbler in the Ubuntu repository still has the old cobbler homepage URL
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
# This will spin up an instance and install cobbler onto it so we can run
|
||||||
|
|
||||||
|
# the Terraform acceptance tests against it.
|
||||||
|
|
||||||
|
module "ami" {
|
||||||
|
source = "github.com/terraform-community-modules/tf_aws_ubuntu_ami/ebs"
|
||||||
|
region = "us-west-2"
|
||||||
|
distribution = "trusty"
|
||||||
|
instance_type = "t2.nano"
|
||||||
|
}
|
||||||
|
|
||||||
|
module "vpc" {
|
||||||
|
source = "github.com/terraform-community-modules/tf_aws_vpc"
|
||||||
|
|
||||||
|
name = "cobbler"
|
||||||
|
cidr = "10.0.0.0/16"
|
||||||
|
private_subnets = "10.0.1.0/24"
|
||||||
|
public_subnets = "10.0.101.0/24"
|
||||||
|
azs = "us-west-2a"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_key_pair" "cobbler" {
|
||||||
|
key_name = "tf-cobbler-acctests"
|
||||||
|
public_key = "${file("~/.ssh/id_rsa.pub")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "cobbler" {
|
||||||
|
vpc_id = "${module.vpc.vpc_id}"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
protocol = "tcp"
|
||||||
|
from_port = 22
|
||||||
|
to_port = 22
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
|
||||||
|
egress {
|
||||||
|
protocol = "-1"
|
||||||
|
from_port = 0
|
||||||
|
to_port = 0
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_instance" "cobbler" {
|
||||||
|
instance_type = "t2.medium"
|
||||||
|
ami = "${module.ami.ami_id}"
|
||||||
|
subnet_id = "${module.vpc.public_subnets}"
|
||||||
|
key_name = "${aws_key_pair.cobbler.id}"
|
||||||
|
vpc_security_group_ids = ["${aws_security_group.cobbler.id}"]
|
||||||
|
|
||||||
|
root_block_device {
|
||||||
|
volume_type = "gp2"
|
||||||
|
volume_size = 40
|
||||||
|
}
|
||||||
|
|
||||||
|
connection {
|
||||||
|
user = "ubuntu"
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "remote-exec" {
|
||||||
|
inline = <<-WAIT
|
||||||
|
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done
|
||||||
|
WAIT
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "remote-exec" {
|
||||||
|
script = "${path.module}/deploy.sh"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output "ssh" {
|
||||||
|
value = "ubuntu@${aws_instance.cobbler.public_ip}"
|
||||||
|
}
|
Loading…
Reference in New Issue