Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
cleaned up Ansible config
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbreak committed Aug 9, 2019
1 parent b8a6cc8 commit b29e549
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 146 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vagrant/
disk-0-1.vdi/
disk-0-2.vdi/
*.retry.yml/
*.retry.yml/
*.py/
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# RHCE 7 Study/Test Environment powered by Ansible and Vagrant.

## Required software before setting up:
## Install the following software before setting up:
###macOS
- [Latest Version of Vagrant](https://www.vagrantup.com/downloads.html) - (`brew cask install vagrant`)
- Vagrant Plugin - `vagrant plugin install vagrant-guest_ansible`
- [Latest Version of Virtualbox](https://www.virtualbox.org/wiki/Downloads) (`brew cask install VirtualBox`)
- Virtual Box Extension Pack (`brew cask install virtualbox-extension-pack`)

If you're using a Mac, Gatekeeper will block virtualbox from installing. All you have to do is go to System Preferences and click Allow under the General tab and rerun installation.

### Install at once with the command below (Linux/Mac only)
`brew install ansible ; brew install python ; brew cask install vagrant ; brew cask install VirtualBox ; brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb ; brew cask install virtualbox-extension-pack`
###Linux/Windows
- [Latest Version of Vagrant](https://www.vagrantup.com/downloads.html) (`wget -c https://releases.hashicorp.com/vagrant/2.0.3/vagrant_2.0.3_x86_64.deb ;sudo dpkg -i vagrant_2.0.3_x86_64.deb`)
- Vagrant Plugin - `vagrant plugin install vagrant-guest_ansible`
- [Latest Version of Virtualbox and Virtual Box Extension Pack](https://www.virtualbox.org/wiki/Downloads), (`sudo apt install vagrant`)

If you're using a Mac, Gatekeeper will block virtualbox from installing. All you have to do is go to System Preferences and click Allow under the General tab and rerun installation.
### (Mac only) Install at once with the command below:
`brew install ansible ; brew install python ; brew cask install vagrant ; brew cask install VirtualBox ; brew cask install virtualbox-extension-pack`

Now you should be ready to follow the next steps and get the deployment up and running!

## Once the above software is installed. Do the following if you're running the environment on Mac/Linux:
1. Create a separate `~/bin` directory and `cd` to it. (The directory doesn't have to be `~/bin`, it can be anything you want.)
Expand Down
194 changes: 116 additions & 78 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,102 +6,140 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use same SSH key for each machine
config.ssh.insert_key = false
config.vm.box_check_update = false
config.vm.define "repo" do |machine|
machine.vm.box = "centos/7"
machine.vm.hostname = "repo.test.example.com"
machine.vm.network "private_network", ip: "192.168.55.19"
machine.vm.network "private_network", ip: "192.168.55.101"
machine.vm.network "private_network", ip: "192.168.55.102"
machine.vm.provision :shell, :inline => " sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; systemctl restart sshd; echo vagrant | passwd vagrant --stdin;", run: "always"
machine.vm.provision :shell, :inline => "sudo yum install -y createrepo wget httpd sshpass| grep -v 'warning\|Error'; sudo cd /etc/pki/rpm-gpg; sudo wget http://yum.theforeman.org/releases/1.8/RPM-GPG-KEY-foreman; sudo rpm --import RPM-GPG-KEY-foreman; sudo rpm -qa gpg* ; sudo rpm -qi gpg-pubkey-225c9b71-54fda121;", run: "always"
machine.vm.provision :shell, :inline => "sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ;", run: "always"
machine.vm.provision :shell, :inline => "sudo mkdir -p /var/www/html/rpms;", run: "always"
# machine.vm.provision :shell, :inline => "for i in \"Development Tools\" \"Server with GUI\" \"File and Print Server\" \"Web Server\" httpd-manual selinux\* sssd\* bash-completion ipa-client man-pages httpd; do yum group install \"$i\" --downloadonly --downloaddir=/var/www/html/rpms;done;", run: "always"
# machine.vm.provision :shell, :inline => "createrepo /var/www/html/rpms", run: "always"
machine.vm.provision :shell, :inline => " sudo systemctl stop packagekit; sudo systemctl mask packagekit", run: "always"
# machine.vm.provision :shell, :inline => " mkdir -p /var/www/html/rpms;", run: "always"
machine.vm.provider "virtualbox" do |machine|
machine.memory = "1024"
config.vm.define "repo" do |repo|
repo.vm.box = "centos/7"
# repo.vm.hostname = "repo.test.example.com"
repo.vm.network "private_network", ip: "192.168.55.19"
repo.vm.network "private_network", ip: "192.168.55.101"
repo.vm.network "private_network", ip: "192.168.55.102"
repo.vm.provision :shell, :inline => " sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; systemctl restart sshd; echo vagrant | passwd vagrant --stdin;", run: "always"
repo.vm.provision :shell, :inline => "sudo yum install -y createrepo wget httpd sshpass| grep -v 'warning\|Error'; sudo cd /etc/pki/rpm-gpg; sudo wget http://yum.theforeman.org/releases/1.8/RPM-GPG-KEY-foreman; sudo rpm --import RPM-GPG-KEY-foreman; sudo rpm -qa gpg* ; sudo rpm -qi gpg-pubkey-225c9b71-54fda121;", run: "always"
repo.vm.provision :shell, :inline => "sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ;", run: "always"
repo.vm.provision :shell, :inline => "sudo mkdir -p /var/www/html/rpms;", run: "always"
repo.vm.provision :shell, :inline => " sudo systemctl stop packagekit; sudo systemctl mask packagekit", run: "always"
repo.vm.provider "virtualbox" do |repo|
repo.memory = "1024"
end
machine.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
machine.vm.provision :shell, :inline => "pip install ansible", run: "always"
# machine.vm.provision :ansible_local do |ansible|
# ansible.playbook = "playbooks/repo.yml"
# ansible.verbose = true
repo.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
repo.vm.provision :shell, :inline => "pip install ansible", run: "always"
repo.vm.synced_folder ".", "/vagrant"
# repo.vm.provision :ansible_local do |ansible|
# ansible.playbook = "/vagrant/playbooks/repo.yml"
# ansible.install = false
# ansible.compatibility_mode = "2.0"
# ansible.config_file = "/vagrant/ansible.cfg"
# end
end
config.vm.define "system1" do |machine|
machine.vm.box = "puppetlabs/centos-7.0-64-nocm"
machine.vm.hostname = "system1.test.example.com"
machine.vm.network "private_network", ip: "192.168.55.21"
machine.vm.network "private_network", ip: "192.168.55.110"
machine.vm.network "private_network", ip: "192.168.55.111"
machine.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd; echo vagrant | sudo passwd vagrant --stdin", run: "always"
machine.vm.provider "virtualbox" do |machine|
machine.memory = "1024"
config.vm.define "system1" do |system1|
system1.vm.box = "puppetlabs/centos-7.0-64-nocm"
# system1.vm.hostname = "system1.test.example.com"
system1.vm.network "private_network", ip: "192.168.55.21"
system1.vm.network "private_network", ip: "192.168.55.110"
system1.vm.network "private_network", ip: "192.168.55.111"
system1.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd; echo vagrant | sudo passwd vagrant --stdin", run: "always"
system1.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
system1.vm.provision :shell, :inline => "sudo yum install -y httpd sshpass", run: "always"
system1.vm.provision :shell, :inline => "pip install ansible", run: "always"
system1.vm.provider "virtualbox" do |system1|
system1.memory = "1024"

if not File.exist?(file_to_disk1)
machine.customize ['createhd', '--filename', file_to_disk1, '--variant', 'Fixed', '--size', 10 * 1024]
system1.customize ['createhd', '--filename', file_to_disk1, '--variant', 'Fixed', '--size', 10 * 1024]
end
machine.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 2]
machine.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk1]
system1.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 2]
system1.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk1]
end

machine.vm.provision "shell", inline: <<-SHELL
system1.vm.provision "shell", inline: <<-SHELL
yes| sudo mkfs.ext4 /dev/sdb
SHELL
machine.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
machine.vm.provision :shell, :inline => "sudo yum install -y httpd sshpass", run: "always"
machine.vm.provision :shell, :inline => "pip install ansible", run: "always"
# machine.vm.provision :ansible_local do |ansible|
# ansible.playbook = "playbooks/system1.yml"
# ansible.verbose = true
# system1.vm.synced_folder ".", "/vagrant"
# system1.vm.provision :ansible_local do |ansible|
# ansible.playbook = "/vagrant/playbooks/system1.yml"
# ansible.install = false
# end
end
config.vm.define "system2" do |machine|
machine.vm.box = "puppetlabs/centos-7.0-64-nocm"
machine.vm.hostname = "system2.test.example.com"
machine.vm.network "private_network", ip: "192.168.55.22"
machine.vm.network "private_network", ip: "192.168.55.112"
machine.vm.network "private_network", ip: "192.168.55.113"
machine.vm.provision :shell, :inline => "sudo yum install -y httpd sshpass", run: "always"
machine.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd; echo vagrant | sudo passwd vagrant --stdin", run: "always"
machine.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
machine.vm.provision :shell, :inline => "pip install ansible", run: "always"
machine.vm.synced_folder ".", "/vagrant"
machine.vm.provider "virtualbox" do |machine|
machine.memory = "1024"
end
config.vm.define "system2" do |system2|
system2.vm.box = "puppetlabs/centos-7.0-64-nocm"
# system2.vm.hostname = "system2.test.example.com"
system2.vm.network "private_network", ip: "192.168.55.22"
system2.vm.network "private_network", ip: "192.168.55.112"
system2.vm.network "private_network", ip: "192.168.55.113"
system2.vm.provision :shell, :inline => "sudo yum install -y httpd sshpass", run: "always"
system2.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd; echo vagrant | sudo passwd vagrant --stdin", run: "always"
system2.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
system2.vm.provision :shell, :inline => "yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y; sudo yum install -y sshpass httpd vsftpd createrepo pki-ca", run: "always"
system2.vm.provision :shell, :inline => "pip install ansible", run: "always"
system2.vm.synced_folder ".", "/vagrant"
system2.vm.provider "virtualbox" do |system2|
system2.memory = "1024"

if not File.exist?(file_to_disk2)
machine.customize ['createhd', '--filename', file_to_disk2, '--variant', 'Fixed', '--size', 10 * 1024]
system2.customize ['createhd', '--filename', file_to_disk2, '--variant', 'Fixed', '--size', 10 * 1024]
end
machine.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 1]
machine.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', file_to_disk2]
system2.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 1]
system2.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', file_to_disk2]
end

machine.vm.provision "shell", inline: <<-SHELL
system2.vm.provision "shell", inline: <<-SHELL
yes| sudo mkfs.ext4 /dev/sdb
SHELL
end

# system2.vm.synced_folder ".", "/vagrant"
# system2.vm.provision :ansible_local do |ansible|
# ansible.playbook = "/vagrant/playbooks/system2.yml"
# ansible.install = false
# end
end

config.vm.define "ipa" do |machine|
machine.vm.box = "centos/7"
machine.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd;", run: "always"
machine.vm.provision :shell, :inline => "sudo yum install -y httpd sshpass", run: "always"
machine.vm.hostname = "ipa.test.example.com"
machine.vm.network "private_network", ip: "192.168.55.20"
machine.vm.provider :virtualbox do |machine|
machine.customize ['modifyvm', :id,'--memory', '2048']
config.vm.define "ipa" do |ipa|
ipa.vm.box = "centos/7"
ipa.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd;", run: "always"
ipa.vm.provision :shell, :inline => "yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y; sudo yum install -y sshpass httpd vsftpd createrepo pki-ca", run: "always"
ipa.vm.provision :shell, :inline => "sudo yum install -y httpd sshpass", run: "always"
# ipa.vm.hostname = "ipa.test.example.com"
ipa.vm.network "private_network", ip: "192.168.55.20"
ipa.vm.provider :virtualbox do |ipa|
ipa.customize ['modifyvm', :id,'--memory', '2048']
end

machine.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
machine.vm.provision :shell, :inline => "pip install ansible", run: "always"
machine.vm.provision :ansible_local do |ansible|
ansible.playbook = "playbooks/master.yml"
# ansible.verbose = true
ansible.inventory_path = "/vagrant/inventory"
ansible.limit = "all"
end
ipa.vm.provision :shell, :inline => "sudo yum group install -y \"Development Tools\" ; sudo yum install -y python-devel curl ;sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; python get-pip.py ; sudo pip install -U pip ; sudo pip install pexpect;", run: "always"
ipa.vm.provision :shell, :inline => "pip install ansible", run: "always"
ipa.vm.synced_folder ".", "/vagrant"
# ipa.vm.provision :ansible_local do |ansible|
# ansible.playbook = "/vagrant/playbooks/ipa.yml"
# ansible.install = false
# ansible.compatibility_mode = "2.0"
# end
# ipa.vm.provision :ansible_local do |ansible|
# ansible.playbook = "/vagrant/playbooks/system1.yml"
# ansible.install = false
# ansible.compatibility_mode = "2.0"
# ansible.inventory_path = "/vagrant/inventory"
# ansible.config_file = "/vagrant/ansible.cfg"
# ansible.limit = "system1"
# end
# ipa.vm.provision :ansible_local do |ansible|
# ansible.playbook = "/vagrant/playbooks/system2.yml"
# ansible.install = false
# ansible.compatibility_mode = "2.0"
# ansible.inventory_path = "/vagrant/inventory"
# ansible.config_file = "/vagrant/ansible.cfg"
# ansible.limit = "system2"
# end
# ipa.vm.provision :ansible_local do |ansible|
# ansible.playbook = "/vagrant/playbooks/kerberos.yml"
# ansible.install = false
# ansible.compatibility_mode = "2.0"
# ansible.inventory_path = "/vagrant/inventory"
# ansible.config_file = "/vagrant/ansible.cfg"
# ansible.limit = "ipa"
# end
ipa.vm.provision :ansible_local do |ansible|
ansible.playbook = "/vagrant/playbooks/master.yml"
ansible.install = false
ansible.compatibility_mode = "2.0"
ansible.inventory_path = "/vagrant/inventory"
ansible.config_file = "/vagrant/ansible.cfg"
ansible.limit = "all"
end
end
end
end
14 changes: 8 additions & 6 deletions inventory
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[all]
ipa.test.example.com ansible_user=vagrant ansible_ssh_pass=vagrant
system2.test.example.com ansible_user=vagrant ansible_ssh_pass=vagrant
repo.test.example.com ansible_host=192.168.55.19 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
ipa.test.example.com ansible_host=192.168.55.20 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
system1.test.example.com ansible_host=192.168.55.21 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
system2.test.example.com ansible_host=192.168.55.22 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
[repo]
repo.test.example.com ansible_user=vagrant ansible_ssh_pass=vagrant
repo.test.example.com ansible_host=192.168.55.19 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
[ipa]
ipa.test.example.com ansible_user=vagrant ansible_ssh_pass=vagrant
ipa.test.example.com ansible_host=192.168.55.20 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
[system1]
system1.test.example.com ansible_user=vagrant ansible_ssh_pass=vagrant
system1.test.example.com ansible_host=192.168.55.21 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
[system2]
system2.test.example.com ansible_user=vagrant ansible_ssh_pass=vagrant
system2.test.example.com ansible_host=192.168.55.22 ansible_user=vagrant ansible_ssh_pass=vagrant ansible_python_interpreter=/usr/bin/python3
Loading

0 comments on commit b29e549

Please sign in to comment.