MultiMachineVagrantPuppetJenkinsNexus: Difference between revisions
No edit summary |
|||
(19 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Multimachine Vagrant boxes with 1 Puppet Server, 1 Puppet Client, and 1 Jenkins/Nexus VM to deploy Tomcat via Puppet | |||
= Vagrant Setup = | = Vagrant Setup = | ||
== Add initial box == | == Add initial box == | ||
< | <syntaxhighlight lang="bash"> | ||
drew@drew-8570w:~$ vagrant box add liatrio/jenkinsnexus | drew@drew-8570w:~$ vagrant box add liatrio/jenkinsnexus | ||
==> box: Loading metadata for box 'liatrio/jenkinsnexus' | ==> box: Loading metadata for box 'liatrio/jenkinsnexus' | ||
Line 8: | Line 9: | ||
box: Downloading: https://atlas.hashicorp.com/liatrio/boxes/jenkinsnexus/versions/0.0.1/providers/virtualbox.box | box: Downloading: https://atlas.hashicorp.com/liatrio/boxes/jenkinsnexus/versions/0.0.1/providers/virtualbox.box | ||
==> box: Successfully added box 'liatrio/jenkinsnexus' (v0.0.1) for 'virtualbox'! | ==> box: Successfully added box 'liatrio/jenkinsnexus' (v0.0.1) for 'virtualbox'! | ||
</ | </syntaxhighlight> | ||
== Initialize box == | == Initialize box == | ||
Builds the ~/Vagrant files | Builds the ~/Vagrant files | ||
< | <syntaxhighlight lang="bash"> | ||
$ vagrant init liatrio/jenkinsnexus | $ vagrant init liatrio/jenkinsnexus | ||
</ | </syntaxhighlight> | ||
= Forward ports = | = Forward ports = | ||
< | <syntaxhighlight lang="bash"> | ||
drew@drew-8570w:~$ diff Vagrantfile Vagrantfile.orig | drew@drew-8570w:~$ diff Vagrantfile Vagrantfile.orig | ||
26,27d25 | 26,27d25 | ||
< config.vm.network "forwarded_port", guest: 8080, host: 18080 | < config.vm.network "forwarded_port", guest: 8080, host: 18080 | ||
< config.vm.network "forwarded_port", guest: 8081, host: 18080 | < config.vm.network "forwarded_port", guest: 8081, host: 18080 | ||
</ | </syntaxhighlight> | ||
== Validate ssh keys == | == Validate ssh keys == | ||
< | <syntaxhighlight lang="bash"> | ||
$ ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/boxes/liatrio-VAGRANTSLASH-jenkinsnexus/0.0.1/virtualbox/vagrant_private_key | $ ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/boxes/liatrio-VAGRANTSLASH-jenkinsnexus/0.0.1/virtualbox/vagrant_private_key | ||
</ | </syntaxhighlight> | ||
= Multi machine vagrant with a private and a nat NIC Vagrantfile = | = Multi machine vagrant with a private and a nat NIC Vagrantfile = | ||
I used the above jenkins nexus box and repackaged it as drew-jenkinsnexus. The puppetmaster and puppetclient boxes were adapted from vagrant public pozgo/centos7 (virtualbox, 2016.02.05) and have puppet server and client configured. Their puppet runs use the modules puppetlabs/tomcat and an something/epel to deploy tomcat with a WAR of spring-samples/petclinic from a Nexus artifact built my Jenkins. | I used the above jenkins nexus box and repackaged it as drew-jenkinsnexus. The puppetmaster and puppetclient boxes were adapted from vagrant public pozgo/centos7 (virtualbox, 2016.02.05) and have puppet server and client configured. Their puppet runs use the modules puppetlabs/tomcat and an something/epel to deploy tomcat with a WAR of spring-samples/petclinic from a Nexus artifact built my Jenkins. | ||
< | <syntaxhighlight lang="bash"> | ||
drew@drew-8570w:~$ cat Vagrantfile | drew@drew-8570w:~$ cat Vagrantfile | ||
Line 88: | Line 89: | ||
end | end | ||
</ | </syntaxhighlight> | ||
= Sample multi machine vagrant up = | = Sample multi machine vagrant up = | ||
Sample successful `vagrant up` output from only having the drew-jenkinsnexus.box, puppetclient.box, puppetmaster.box, and Vagrantfile. | Sample successful `vagrant up` output from only having the drew-jenkinsnexus.box, puppetclient.box, puppetmaster.box, and Vagrantfile. | ||
< | <syntaxhighlight lang="bash"> | ||
drew@drew-8570w:~$ vagrant up | drew@drew-8570w:~$ vagrant up | ||
Bringing machine 'jenkinsnexus' up with 'virtualbox' provider... | Bringing machine 'jenkinsnexus' up with 'virtualbox' provider... | ||
Line 107: | Line 108: | ||
==> jenkinsnexus: Matching MAC address for NAT networking... | ==> jenkinsnexus: Matching MAC address for NAT networking... | ||
==> jenkinsnexus: Setting the name of the VM: drew_jenkinsnexus_1455246067848_9962 | ==> jenkinsnexus: Setting the name of the VM: drew_jenkinsnexus_1455246067848_9962 | ||
==> jenkinsnexus: Clearing any | ==> jenkinsnexus: Clearing any syntaxhighlightviously set network interfaces... | ||
==> jenkinsnexus: | ==> jenkinsnexus: syntaxhighlightparing network interfaces based on configuration... | ||
jenkinsnexus: Adapter 1: nat | jenkinsnexus: Adapter 1: nat | ||
jenkinsnexus: Adapter 2: hostonly | jenkinsnexus: Adapter 2: hostonly | ||
Line 115: | Line 116: | ||
jenkinsnexus: 8080 (guest) => 18080 (host) (adapter 1) | jenkinsnexus: 8080 (guest) => 18080 (host) (adapter 1) | ||
jenkinsnexus: 8081 (guest) => 18081 (host) (adapter 1) | jenkinsnexus: 8081 (guest) => 18081 (host) (adapter 1) | ||
==> jenkinsnexus: Running ' | ==> jenkinsnexus: Running 'syntaxhighlight-boot' VM customizations... | ||
==> jenkinsnexus: Booting VM... | ==> jenkinsnexus: Booting VM... | ||
==> jenkinsnexus: Waiting for machine to boot. This may take a few minutes... | ==> jenkinsnexus: Waiting for machine to boot. This may take a few minutes... | ||
Line 138: | Line 139: | ||
==> puppetmaster: Matching MAC address for NAT networking... | ==> puppetmaster: Matching MAC address for NAT networking... | ||
==> puppetmaster: Setting the name of the VM: drew_puppetmaster_1455246121351_2019 | ==> puppetmaster: Setting the name of the VM: drew_puppetmaster_1455246121351_2019 | ||
==> puppetmaster: Clearing any | ==> puppetmaster: Clearing any syntaxhighlightviously set network interfaces... | ||
==> puppetmaster: | ==> puppetmaster: syntaxhighlightparing network interfaces based on configuration... | ||
puppetmaster: Adapter 1: nat | puppetmaster: Adapter 1: nat | ||
puppetmaster: Adapter 2: hostonly | puppetmaster: Adapter 2: hostonly | ||
==> puppetmaster: Forwarding ports... | ==> puppetmaster: Forwarding ports... | ||
puppetmaster: 22 (guest) => 2230 (host) (adapter 1) | puppetmaster: 22 (guest) => 2230 (host) (adapter 1) | ||
==> puppetmaster: Running ' | ==> puppetmaster: Running 'syntaxhighlight-boot' VM customizations... | ||
==> puppetmaster: Booting VM... | ==> puppetmaster: Booting VM... | ||
==> puppetmaster: Waiting for machine to boot. This may take a few minutes... | ==> puppetmaster: Waiting for machine to boot. This may take a few minutes... | ||
Line 156: | Line 157: | ||
puppetmaster: | puppetmaster: | ||
puppetmaster: Inserting generated public key within guest... | puppetmaster: Inserting generated public key within guest... | ||
puppetmaster: Removing insecure key from the guest if it's | puppetmaster: Removing insecure key from the guest if it's syntaxhighlightsent... | ||
puppetmaster: Key inserted! Disconnecting and reconnecting using new SSH key... | puppetmaster: Key inserted! Disconnecting and reconnecting using new SSH key... | ||
==> puppetmaster: Machine booted and ready! | ==> puppetmaster: Machine booted and ready! | ||
Line 174: | Line 175: | ||
==> puppetclient: Matching MAC address for NAT networking... | ==> puppetclient: Matching MAC address for NAT networking... | ||
==> puppetclient: Setting the name of the VM: drew_puppetclient_1455246176072_64531 | ==> puppetclient: Setting the name of the VM: drew_puppetclient_1455246176072_64531 | ||
==> puppetclient: Clearing any | ==> puppetclient: Clearing any syntaxhighlightviously set network interfaces... | ||
==> puppetclient: | ==> puppetclient: syntaxhighlightparing network interfaces based on configuration... | ||
puppetclient: Adapter 1: nat | puppetclient: Adapter 1: nat | ||
puppetclient: Adapter 2: hostonly | puppetclient: Adapter 2: hostonly | ||
Line 181: | Line 182: | ||
puppetclient: 22 (guest) => 2231 (host) (adapter 1) | puppetclient: 22 (guest) => 2231 (host) (adapter 1) | ||
puppetclient: 8080 (guest) => 8080 (host) (adapter 1) | puppetclient: 8080 (guest) => 8080 (host) (adapter 1) | ||
==> puppetclient: Running ' | ==> puppetclient: Running 'syntaxhighlight-boot' VM customizations... | ||
==> puppetclient: Booting VM... | ==> puppetclient: Booting VM... | ||
==> puppetclient: Waiting for machine to boot. This may take a few minutes... | ==> puppetclient: Waiting for machine to boot. This may take a few minutes... | ||
Line 193: | Line 194: | ||
puppetclient: | puppetclient: | ||
puppetclient: Inserting generated public key within guest... | puppetclient: Inserting generated public key within guest... | ||
puppetclient: Removing insecure key from the guest if it's | puppetclient: Removing insecure key from the guest if it's syntaxhighlightsent... | ||
puppetclient: Key inserted! Disconnecting and reconnecting using new SSH key... | puppetclient: Key inserted! Disconnecting and reconnecting using new SSH key... | ||
==> puppetclient: Machine booted and ready! | ==> puppetclient: Machine booted and ready! | ||
Line 201: | Line 202: | ||
==> puppetclient: Mounting shared folders... | ==> puppetclient: Mounting shared folders... | ||
puppetclient: /vagrant => /home/drew | puppetclient: /vagrant => /home/drew | ||
</ | </syntaxhighlight> | ||
= Setup Jenkins = | = Setup Jenkins = | ||
http://localhost:18080/ | http://localhost:18080/ | ||
< | <syntaxhighlight lang="bash"> | ||
> Install GitHub Plugin | > Install GitHub Plugin | ||
> Credentials > Global Credentials > added my github key | > Credentials > Global Credentials > added my github key | ||
Line 215: | Line 216: | ||
> Git > [email protected]:spring-projects/spring-petclinic.git > Credentials > drewderivative | > Git > [email protected]:spring-projects/spring-petclinic.git > Credentials > drewderivative | ||
> Build when a change is pushed to GitHub | > Build when a change is pushed to GitHub | ||
</ | </syntaxhighlight> | ||
= Setup Nexus = | = Setup Nexus = | ||
< | <syntaxhighlight lang="bash"> | ||
http://localhost:18081/nexus/ | http://localhost:18081/nexus/ | ||
admin :: admin123 | admin :: admin123 | ||
* http://localhost:18081/nexus/content/repositories/releases/ | * http://localhost:18081/nexus/content/repositories/releases/ | ||
</ | </syntaxhighlight> | ||
= Setup Puppetserver = | = Setup Puppetserver = | ||
< | <syntaxhighlight lang="bash"> | ||
# yum -y install chrony; systemctl start chronyd | # yum -y install chrony; systemctl start chronyd | ||
# firewall-cmd --permanent --zone=public --add-port=8140/tcp | # firewall-cmd --permanent --zone=public --add-port=8140/tcp | ||
Line 234: | Line 235: | ||
# sudo puppet master --verbose --no-daemonize | # sudo puppet master --verbose --no-daemonize | ||
^C after its successful or it will run forever. | ^C after its successful or it will run forever. | ||
</ | </syntaxhighlight> | ||
/etc/puppet/puppet.conf | /etc/puppet/puppet.conf | ||
< | <syntaxhighlight lang="bash"> | ||
[main] | [main] | ||
certname = puppetmaster.xyz.local | certname = puppetmaster.xyz.local | ||
Line 252: | Line 253: | ||
classfile = $vardir/classes.txt | classfile = $vardir/classes.txt | ||
localconfig = $vardir/localconfig | localconfig = $vardir/localconfig | ||
</ | </syntaxhighlight> | ||
= Enable/Start Puppetserver = | = Enable/Start Puppetserver = | ||
< | <syntaxhighlight lang="bash"> | ||
sudo ssystemctl enable puppetserver; sudo systemctl start puppetserver | sudo ssystemctl enable puppetserver; sudo systemctl start puppetserver | ||
</ | </syntaxhighlight> | ||
= Client puppet.conf = | = Client puppet.conf = | ||
< | <syntaxhighlight lang="bash"> | ||
[root@puppetclient ~]# grep -vE '^($| #)' /etc/puppet/puppet.conf | [root@puppetclient ~]# grep -vE '^($| #)' /etc/puppet/puppet.conf | ||
[main] | [main] | ||
Line 272: | Line 273: | ||
server = puppetmaster.xyz.local | server = puppetmaster.xyz.local | ||
runinterval = 600 | runinterval = 600 | ||
</ | </syntaxhighlight> | ||
= Configure site.pp and node.pp = | = Configure site.pp and node.pp = | ||
< | <syntaxhighlight lang="bash"> | ||
[root@puppetmaster ~]# cat /etc/puppet/manifests/site.pp | [root@puppetmaster ~]# cat /etc/puppet/manifests/site.pp | ||
import 'nodes.pp' | import 'nodes.pp' | ||
$puppetmaster = 'puppetmaster.xyz.local' | $puppetmaster = 'puppetmaster.xyz.local' | ||
</ | </syntaxhighlight> | ||
* Note - Usually install modules first then adapt nodes.pp | * Note - Usually install modules first then adapt nodes.pp | ||
< | <syntaxhighlight lang="bash"> | ||
[vagrant@puppetmaster ~]$ cat /etc/puppet/manifests/nodes.pp | [vagrant@puppetmaster ~]$ cat /etc/puppet/manifests/nodes.pp | ||
node 'puppetclient.xyz.local' { | node 'puppetclient.xyz.local' { | ||
Line 309: | Line 310: | ||
} | } | ||
</ | </syntaxhighlight> | ||
= Add puppet modules = | = Add puppet modules = | ||
== Motd == | == Motd == | ||
Used simple puppetlabs/motd to ensure puppet runs were working. Added to node.pp `import motd`. | Used simple puppetlabs/motd to ensure puppet runs were working. Added to node.pp `import motd`. | ||
< | <syntaxhighlight lang="bash"> | ||
[root@puppetmaster manifests]# puppet module install puppetlabs/motd | [root@puppetmaster manifests]# puppet module install puppetlabs/motd | ||
</ | </syntaxhighlight> | ||
== EPEL == | == EPEL == | ||
< | <syntaxhighlight lang="bash"> | ||
[root@puppetmaster manifests]# puppet module install stahnma-epel | [root@puppetmaster manifests]# puppet module install stahnma-epel | ||
Notice: | Notice: syntaxhighlightparing to install into /etc/puppet/modules ... | ||
Notice: Downloading from https://forgeapi.puppetlabs.com ... | Notice: Downloading from https://forgeapi.puppetlabs.com ... | ||
Notice: Installing -- do not interrupt ... | Notice: Installing -- do not interrupt ... | ||
Line 327: | Line 328: | ||
└─┬ stahnma-epel (v1.2.2) | └─┬ stahnma-epel (v1.2.2) | ||
└── puppetlabs-stdlib (v4.11.0) | └── puppetlabs-stdlib (v4.11.0) | ||
</ | </syntaxhighlight> | ||
== Tomcat == | == Tomcat == | ||
< | <syntaxhighlight lang="bash"> | ||
[root@puppetmaster ~]# puppet module install puppetlabs-tomcat | [root@puppetmaster ~]# puppet module install puppetlabs-tomcat | ||
Notice: | Notice: syntaxhighlightparing to install into /etc/puppet/modules ... | ||
Notice: Downloading from https://forgeapi.puppetlabs.com ... | Notice: Downloading from https://forgeapi.puppetlabs.com ... | ||
Notice: Installing -- do not interrupt ... | Notice: Installing -- do not interrupt ... | ||
Line 345: | Line 346: | ||
http://localhost:8080/spring-petclinic/ | http://localhost:8080/spring-petclinic/ | ||
</ | </syntaxhighlight> | ||
= petclinic pom.xml = | = petclinic pom.xml for nexus = | ||
/var/lib/jenkins/jobs/petclinic-simple-auto-1/workspace/pom.xml | /var/lib/jenkins/jobs/petclinic-simple-auto-1/workspace/pom.xml | ||
< | <syntaxhighlight lang="bash"> | ||
.. | .. | ||
.. | .. | ||
Line 366: | Line 367: | ||
<url>demopetclinic</url> | <url>demopetclinic</url> | ||
</project> | </project> | ||
</ | </syntaxhighlight> | ||
= petclinic pom.xml for archiva = | |||
<syntaxhighlight lang="bash"> | |||
<distributionManagement> | |||
<snapshotRepository> | |||
<id>deploy</id> | |||
<url>http://192.168.100.30:8080/repository/internal/</url> | |||
</snapshotRepository> | |||
<repository> | |||
<id>snapshots</id> | |||
<url>http://192.168.100.30:8080/repository/snapshots/</url> | |||
</repository> | |||
</distributionManagement> | |||
</syntaxhighlight> | |||
or | |||
<syntaxhighlight lang="bash"> | |||
<distributionManagement> | |||
<repository> | |||
<id>repository-1</id> | |||
<url>http://localhost:8081/repository/internal/</url> | |||
<releases> | |||
<enabled>true</enabled> | |||
</releases> | |||
<snapshots> | |||
<enabled>true</enabled> | |||
</snapshots> | |||
</repository> | |||
</distributionManagement> | |||
</syntaxhighlight> | |||
= ~/.m2/settings.xml = | |||
<syntaxhighlight lang="bash"> | |||
[vagrant@localhost conf]$ cat /var/lib/jenkins/.m2/settings.xml | |||
<settings> | |||
<mirrors> | |||
<mirror> | |||
<id>archiva.default</id> | |||
<name>Proxy Cache - Internal Repository</name> | |||
<url>http://192.168.100.30:8080/repository/internal</url> | |||
<mirrorOf>*</mirrorOf> | |||
</mirror> | |||
</mirrors> | |||
<servers> | |||
<server> | |||
<id>deployment</id> | |||
<username>deploy</username> | |||
<password>deploy1</password> | |||
</server> | |||
<server> | |||
<id>snapshots</id> | |||
<username>snapshots</username> | |||
<password>snapshots1</password> | |||
</server> | |||
</servers> | |||
</settings> | |||
</syntaxhighlight> | |||
= To-do = | = To-do = | ||
configure pom.xml to use Nexus artifacts instead of maven central | configure pom.xml to use Nexus artifacts instead of maven central |
Latest revision as of 17:30, 9 January 2018
Multimachine Vagrant boxes with 1 Puppet Server, 1 Puppet Client, and 1 Jenkins/Nexus VM to deploy Tomcat via Puppet
Vagrant Setup
Add initial box
drew@drew-8570w:~$ vagrant box add liatrio/jenkinsnexus
==> box: Loading metadata for box 'liatrio/jenkinsnexus'
box: URL: https://atlas.hashicorp.com/liatrio/jenkinsnexus
==> box: Adding box 'liatrio/jenkinsnexus' (v0.0.1) for provider: virtualbox
box: Downloading: https://atlas.hashicorp.com/liatrio/boxes/jenkinsnexus/versions/0.0.1/providers/virtualbox.box
==> box: Successfully added box 'liatrio/jenkinsnexus' (v0.0.1) for 'virtualbox'!
Initialize box
Builds the ~/Vagrant files
$ vagrant init liatrio/jenkinsnexus
Forward ports
drew@drew-8570w:~$ diff Vagrantfile Vagrantfile.orig
26,27d25
< config.vm.network "forwarded_port", guest: 8080, host: 18080
< config.vm.network "forwarded_port", guest: 8081, host: 18080
Validate ssh keys
$ ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/boxes/liatrio-VAGRANTSLASH-jenkinsnexus/0.0.1/virtualbox/vagrant_private_key
Multi machine vagrant with a private and a nat NIC Vagrantfile
I used the above jenkins nexus box and repackaged it as drew-jenkinsnexus. The puppetmaster and puppetclient boxes were adapted from vagrant public pozgo/centos7 (virtualbox, 2016.02.05) and have puppet server and client configured. Their puppet runs use the modules puppetlabs/tomcat and an something/epel to deploy tomcat with a WAR of spring-samples/petclinic from a Nexus artifact built my Jenkins.
drew@drew-8570w:~$ cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.define "jenkinsnexus" do |jenknex|
jenknex.vm.box = "drew-jenkinsnexus"
jenknex.vm.hostname = 'jenkinsnexus.xyz.local'
jenknex.vm.box_url = "~/drew-jenkinsnexus.box"
jenknex.vm.network :private_network, ip: "192.168.100.20"
jenknex.vm.network :forwarded_port, guest: 22, host: 2220, id: "ssh"
jenknex.vm.network :forwarded_port, guest: 8080, host: 18080
jenknex.vm.network :forwarded_port, guest: 8081, host: 18081
jenknex.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--cpus", 4]
v.customize ["modifyvm", :id, "--memory", 4096]
v.customize ["modifyvm", :id, "--name", "drew-jenkinsnexus"]
end
end
config.vm.define "puppetmaster" do |master|
master.vm.box = "puppetmaster"
master.vm.hostname = 'puppetmaster.xyz.local'
master.vm.box_url = "~/puppetmaster.box"
master.vm.network :private_network, ip: "192.168.100.30"
master.vm.network :forwarded_port, guest: 22, host: 2230, id: "ssh"
master.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--cpus", 2]
v.customize ["modifyvm", :id, "--memory", 4096]
v.customize ["modifyvm", :id, "--name", "puppetmaster"]
end
end
config.vm.define "puppetclient" do |client|
client.vm.box = "puppetclient"
client.vm.hostname = 'puppetclient.xyz.local'
client.vm.box_url = "~/puppetclient.box"
client.vm.network :private_network, ip: "192.168.100.31"
client.vm.network :forwarded_port, guest: 22, host: 2231, id: "ssh"
client.vm.network :forwarded_port, guest: 8080, host: 8080, id: "http"
client.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--cpus", 2]
v.customize ["modifyvm", :id, "--memory", 2048]
v.customize ["modifyvm", :id, "--name", "puppetclient"]
end
end
end
Sample multi machine vagrant up
Sample successful `vagrant up` output from only having the drew-jenkinsnexus.box, puppetclient.box, puppetmaster.box, and Vagrantfile.
drew@drew-8570w:~$ vagrant up
Bringing machine 'jenkinsnexus' up with 'virtualbox' provider...
Bringing machine 'puppetmaster' up with 'virtualbox' provider...
Bringing machine 'puppetclient' up with 'virtualbox' provider...
==> jenkinsnexus: Box 'drew-jenkinsnexus' could not be found. Attempting to find and install...
jenkinsnexus: Box Provider: virtualbox
jenkinsnexus: Box Version: >= 0
==> jenkinsnexus: Box file was not detected as metadata. Adding it directly...
==> jenkinsnexus: Adding box 'drew-jenkinsnexus' (v0) for provider: virtualbox
jenkinsnexus: Unpacking necessary files from: file:///home/drew/drew-jenkinsnexus.box
jenkinsnexus: Progress: 51% (Rate: 1580M/s, Estimated time remaining: 0:00:0==> jenkinsnexus: Successfully added box 'drew-jenkinsnexus' (v0) for 'virtualbox'!
==> jenkinsnexus: Importing base box 'drew-jenkinsnexus'...
==> jenkinsnexus: Matching MAC address for NAT networking...
==> jenkinsnexus: Setting the name of the VM: drew_jenkinsnexus_1455246067848_9962
==> jenkinsnexus: Clearing any syntaxhighlightviously set network interfaces...
==> jenkinsnexus: syntaxhighlightparing network interfaces based on configuration...
jenkinsnexus: Adapter 1: nat
jenkinsnexus: Adapter 2: hostonly
==> jenkinsnexus: Forwarding ports...
jenkinsnexus: 22 (guest) => 2220 (host) (adapter 1)
jenkinsnexus: 8080 (guest) => 18080 (host) (adapter 1)
jenkinsnexus: 8081 (guest) => 18081 (host) (adapter 1)
==> jenkinsnexus: Running 'syntaxhighlight-boot' VM customizations...
==> jenkinsnexus: Booting VM...
==> jenkinsnexus: Waiting for machine to boot. This may take a few minutes...
jenkinsnexus: SSH address: 127.0.0.1:2220
jenkinsnexus: SSH username: vagrant
jenkinsnexus: SSH auth method: private key
jenkinsnexus: Warning: Remote connection disconnect. Retrying...
==> jenkinsnexus: Machine booted and ready!
==> jenkinsnexus: Checking for guest additions in VM...
==> jenkinsnexus: Setting hostname...
==> jenkinsnexus: Configuring and enabling network interfaces...
==> jenkinsnexus: Mounting shared folders...
jenkinsnexus: /vagrant => /home/drew
==> puppetmaster: Box 'puppetmaster' could not be found. Attempting to find and install...
puppetmaster: Box Provider: virtualbox
puppetmaster: Box Version: >= 0
==> puppetmaster: Box file was not detected as metadata. Adding it directly...
==> puppetmaster: Adding box 'puppetmaster' (v0) for provider: virtualbox
puppetmaster: Unpacking necessary files from: file:///home/drew/puppetmaster.box
==> puppetmaster: Successfully added box 'puppetmaster' (v0) for 'virtualbox'!
==> puppetmaster: Importing base box 'puppetmaster'...
==> puppetmaster: Matching MAC address for NAT networking...
==> puppetmaster: Setting the name of the VM: drew_puppetmaster_1455246121351_2019
==> puppetmaster: Clearing any syntaxhighlightviously set network interfaces...
==> puppetmaster: syntaxhighlightparing network interfaces based on configuration...
puppetmaster: Adapter 1: nat
puppetmaster: Adapter 2: hostonly
==> puppetmaster: Forwarding ports...
puppetmaster: 22 (guest) => 2230 (host) (adapter 1)
==> puppetmaster: Running 'syntaxhighlight-boot' VM customizations...
==> puppetmaster: Booting VM...
==> puppetmaster: Waiting for machine to boot. This may take a few minutes...
puppetmaster: SSH address: 127.0.0.1:2230
puppetmaster: SSH username: vagrant
puppetmaster: SSH auth method: private key
puppetmaster: Warning: Remote connection disconnect. Retrying...
puppetmaster:
puppetmaster: Vagrant insecure key detected. Vagrant will automatically replace
puppetmaster: this with a newly generated keypair for better security.
puppetmaster:
puppetmaster: Inserting generated public key within guest...
puppetmaster: Removing insecure key from the guest if it's syntaxhighlightsent...
puppetmaster: Key inserted! Disconnecting and reconnecting using new SSH key...
==> puppetmaster: Machine booted and ready!
==> puppetmaster: Checking for guest additions in VM...
==> puppetmaster: Setting hostname...
==> puppetmaster: Configuring and enabling network interfaces...
==> puppetmaster: Mounting shared folders...
puppetmaster: /vagrant => /home/drew
==> puppetclient: Box 'puppetclient' could not be found. Attempting to find and install...
puppetclient: Box Provider: virtualbox
puppetclient: Box Version: >= 0
==> puppetclient: Box file was not detected as metadata. Adding it directly...
==> puppetclient: Adding box 'puppetclient' (v0) for provider: virtualbox
puppetclient: Unpacking necessary files from: file:///home/drew/puppetclient.box
puppetclient: Progress: 29% (Rate: 1245M/s, Estimated time remaining: --:--:==> puppetclient: Successfully added box 'puppetclient' (v0) for 'virtualbox'!
==> puppetclient: Importing base box 'puppetclient'...
==> puppetclient: Matching MAC address for NAT networking...
==> puppetclient: Setting the name of the VM: drew_puppetclient_1455246176072_64531
==> puppetclient: Clearing any syntaxhighlightviously set network interfaces...
==> puppetclient: syntaxhighlightparing network interfaces based on configuration...
puppetclient: Adapter 1: nat
puppetclient: Adapter 2: hostonly
==> puppetclient: Forwarding ports...
puppetclient: 22 (guest) => 2231 (host) (adapter 1)
puppetclient: 8080 (guest) => 8080 (host) (adapter 1)
==> puppetclient: Running 'syntaxhighlight-boot' VM customizations...
==> puppetclient: Booting VM...
==> puppetclient: Waiting for machine to boot. This may take a few minutes...
puppetclient: SSH address: 127.0.0.1:2231
puppetclient: SSH username: vagrant
puppetclient: SSH auth method: private key
puppetclient: Warning: Remote connection disconnect. Retrying...
puppetclient:
puppetclient: Vagrant insecure key detected. Vagrant will automatically replace
puppetclient: this with a newly generated keypair for better security.
puppetclient:
puppetclient: Inserting generated public key within guest...
puppetclient: Removing insecure key from the guest if it's syntaxhighlightsent...
puppetclient: Key inserted! Disconnecting and reconnecting using new SSH key...
==> puppetclient: Machine booted and ready!
==> puppetclient: Checking for guest additions in VM...
==> puppetclient: Setting hostname...
==> puppetclient: Configuring and enabling network interfaces...
==> puppetclient: Mounting shared folders...
puppetclient: /vagrant => /home/drew
Setup Jenkins
> Install GitHub Plugin
> Credentials > Global Credentials > added my github key
> Manage > Plugins > Installed GitHub Plugin
> petclinic-simple-auto-1 > Configure >
> GitHub Project > https URL of my forked spring-petclinic
> Git > [email protected]:spring-projects/spring-petclinic.git > Credentials > drewderivative
> Build when a change is pushed to GitHub
Setup Nexus
http://localhost:18081/nexus/
admin :: admin123
* http://localhost:18081/nexus/content/repositories/releases/
Setup Puppetserver
# yum -y install chrony; systemctl start chronyd
# firewall-cmd --permanent --zone=public --add-port=8140/tcp
# firewall-cmd --reload
# sudo rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
# sudo yum install puppetserver
# sudo puppet master --verbose --no-daemonize
^C after its successful or it will run forever.
/etc/puppet/puppet.conf
[main]
certname = puppetmaster.xyz.local
servername = puppetmaster.xyz.local
logdir = /var/log/puppet
rundir = /var/run/puppet
[master]
certname = puppetmaster.xyz.local
dns_alt_names = puppetmaster,puppetmaster.xyz.local
autosign = true
[agent]
classfile = $vardir/classes.txt
localconfig = $vardir/localconfig
Enable/Start Puppetserver
sudo ssystemctl enable puppetserver; sudo systemctl start puppetserver
Client puppet.conf
[root@puppetclient ~]# grep -vE '^($| #)' /etc/puppet/puppet.conf
[main]
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = $vardir/ssl
[agent]
classfile = $vardir/classes.txt
localconfig = $vardir/localconfig
ca_server = puppetmaster.xyz.local
server = puppetmaster.xyz.local
runinterval = 600
Configure site.pp and node.pp
[root@puppetmaster ~]# cat /etc/puppet/manifests/site.pp
import 'nodes.pp'
$puppetmaster = 'puppetmaster.xyz.local'
- Note - Usually install modules first then adapt nodes.pp
[vagrant@puppetmaster ~]$ cat /etc/puppet/manifests/nodes.pp
node 'puppetclient.xyz.local' {
include motd
class { 'epel': }->
tomcat::instance{ 'default':
package_name => 'tomcat',
}
class { 'tomcat':
install_from_source => false,
}
tomcat::service { 'default':
use_jsvc => false,
use_init => true,
service_name => 'tomcat',
}
tomcat::war { 'spring-petclinic.war':
catalina_base => '/usr/share/tomcat',
war_source => 'http://192.168.100.20:8081/nexus/content/repositories/snapshots/org/springframework/samples/spring-petclinic/4.2.4-SNAPSHOT/spring-petclinic-4.2.4-20160211.001608-8.war',
}
}
Add puppet modules
Motd
Used simple puppetlabs/motd to ensure puppet runs were working. Added to node.pp `import motd`.
[root@puppetmaster manifests]# puppet module install puppetlabs/motd
EPEL
[root@puppetmaster manifests]# puppet module install stahnma-epel
Notice: syntaxhighlightparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ stahnma-epel (v1.2.2)
└── puppetlabs-stdlib (v4.11.0)
Tomcat
[root@puppetmaster ~]# puppet module install puppetlabs-tomcat
Notice: syntaxhighlightparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ puppetlabs-tomcat (v1.4.1)
├── nanliu-staging (v1.0.3)
├── puppetlabs-concat (v1.2.5)
└── puppetlabs-stdlib (v4.11.0)
[root@puppetmaster ~]# firewall-cmd --permanent --zone=public --add-port=8080/tcp
[root@puppetmaster ~]# firewall-cmd --reload
[root@puppetmaster ~]# sudo yum -y install tomcat-webapps tomcat-admin-webapps
http://localhost:8080/spring-petclinic/
petclinic pom.xml for nexus
/var/lib/jenkins/jobs/petclinic-simple-auto-1/workspace/pom.xml
..
..
</profiles>
<distributionManagement>
<snapshotRepository>
<id>deployment</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>deployment</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>
<url>demopetclinic</url>
</project>
petclinic pom.xml for archiva
<distributionManagement>
<snapshotRepository>
<id>deploy</id>
<url>http://192.168.100.30:8080/repository/internal/</url>
</snapshotRepository>
<repository>
<id>snapshots</id>
<url>http://192.168.100.30:8080/repository/snapshots/</url>
</repository>
</distributionManagement>
or
<distributionManagement>
<repository>
<id>repository-1</id>
<url>http://localhost:8081/repository/internal/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
~/.m2/settings.xml
[vagrant@localhost conf]$ cat /var/lib/jenkins/.m2/settings.xml
<settings>
<mirrors>
<mirror>
<id>archiva.default</id>
<name>Proxy Cache - Internal Repository</name>
<url>http://192.168.100.30:8080/repository/internal</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>deployment</id>
<username>deploy</username>
<password>deploy1</password>
</server>
<server>
<id>snapshots</id>
<username>snapshots</username>
<password>snapshots1</password>
</server>
</servers>
</settings>
To-do
configure pom.xml to use Nexus artifacts instead of maven central