github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/cobbler/acceptance_env/deploy.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  # This script assumes Ubuntu 14.04 is being used.
     6  # It will create a standard Cobbler environment that can be used for acceptance testing.
     7  
     8  # With this enviornment spun up, the config should be:
     9  #  COBBLER_URL=http://127.0.0.1:25151
    10  #  COBBLER_USERNAME=cobbler
    11  #  COBBLER_PASSWORD=cobbler
    12  
    13  sudo apt-get update
    14  sudo apt-get install -y build-essential git mercurial
    15  
    16  cd
    17  echo 'export PATH=$PATH:$HOME/terraform:$HOME/go/bin' >> ~/.bashrc
    18  export PATH=$PATH:$HOME/terraform:$HOME/go/bin
    19  
    20  sudo wget -O /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
    21  sudo chmod +x /usr/local/bin/gimme
    22  /usr/local/bin/gimme 1.6 >> ~/.bashrc
    23  eval "$(/usr/local/bin/gimme 1.6)"
    24  
    25  mkdir ~/go
    26  echo 'export GOPATH=$HOME/go' >> ~/.bashrc
    27  echo 'export GO15VENDOREXPERIMENT=1' >> ~/.bashrc
    28  export GOPATH=$HOME/go
    29  source ~/.bashrc
    30  
    31  go get github.com/tools/godep
    32  go get github.com/hashicorp/terraform
    33  cd $GOPATH/src/github.com/hashicorp/terraform
    34  godep restore
    35  
    36  # Cobbler
    37  sudo apt-get install -y cobbler cobbler-web debmirror dnsmasq
    38  
    39  sudo tee /etc/cobbler/modules.conf <<EOF
    40  [authentication]
    41  module = authn_configfile
    42  [authorization]
    43  module = authz_allowall
    44  [dns]
    45  module = manage_dnsmasq
    46  [dhcp]
    47  module = manage_dnsmasq
    48  [tftpd]
    49  module = manage_in_tftpd
    50  EOF
    51  
    52  sudo tee /etc/cobbler/dnsmasq.template <<EOF
    53  dhcp-range = 192.168.255.200,192.168.255.250
    54  server = 8.8.8.8
    55  read-ethers
    56  addn-hosts = /var/lib/cobbler/cobbler_hosts
    57  
    58  dhcp-option=3,\$next_server
    59  dhcp-lease-max=1000
    60  dhcp-authoritative
    61  dhcp-boot=pxelinux.0
    62  dhcp-boot=net:normalarch,pxelinux.0
    63  dhcp-boot=net:ia64,\$elilo
    64  
    65  \$insert_cobbler_system_definitions
    66  EOF
    67  
    68  sudo sed -i -e 's/^manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
    69  sudo sed -i -e 's/^manage_dns: 0/manage_dns: 1/' /etc/cobbler/settings
    70  sudo sed -i -e 's/^next_server:.*/next_server: 127.0.0.1/' /etc/cobbler/settings
    71  sudo sed -i -e 's/^server:.*/server: 127.0.0.1/' /etc/cobbler/settings
    72  
    73  # User: cobbler / Pass: cobbler
    74  sudo tee /etc/cobbler/users.digest <<EOF
    75  cobbler:Cobbler:2d6bae81669d707b72c0bd9806e01f3
    76  EOF
    77  
    78  # The stock version of Cobbler in the Ubuntu repository still has the old cobbler homepage URL
    79  sudo sed -i -e 's#content_server = "http://www.cobblerd.org/loaders"#content_server = "http://cobbler.github.com/loaders"#' /usr/lib/python2.7/dist-packages/cobbler/action_dlcontent.py
    80  sudo rm /usr/lib/python2.7/dist-packages/cobbler/action_dlcontent.pyc
    81  
    82  sudo /etc/init.d/apache2 restart
    83  sudo stop cobbler
    84  sleep 2
    85  sudo start cobbler
    86  sleep 10
    87  sudo cobbler get-loaders
    88  sudo cobbler sync
    89  
    90  # Import an Ubuntu 1404 distro
    91  cd /tmp
    92  wget http://old-releases.ubuntu.com/releases/14.04.2/ubuntu-14.04-server-amd64.iso
    93  sudo mount -o loop ubuntu-14.04-server-amd64.iso /mnt
    94  sudo cobbler import --name Ubuntu-14.04 --breed ubuntu --path /mnt