<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jboss Archives -</title>
	<atom:link href="https://barriersec.com/tag/jboss/feed/" rel="self" type="application/rss+xml" />
	<link>https://barriersec.com/tag/jboss/</link>
	<description></description>
	<lastBuildDate>Mon, 14 Sep 2020 03:19:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.15</generator>

<image>
	<url>https://barriersec.com/wp-content/uploads/cropped-Monochrome-on-Transparent-32x32.png</url>
	<title>jboss Archives -</title>
	<link>https://barriersec.com/tag/jboss/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Introduction to Ansible Part 3</title>
		<link>https://barriersec.com/2018/09/introduction-to-ansible-part-3/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 22 Sep 2018 17:44:26 +0000</pubDate>
				<category><![CDATA[Introduction to Ansible Part 3]]></category>
		<category><![CDATA[ansible]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[jboss]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=217</guid>

					<description><![CDATA[<p>Hi there! Its been a long time since i posted continuation series on Ansible . if you have not read&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/introduction-to-ansible-part-3/">Introduction to Ansible Part 3</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi there! Its been a long time since i posted continuation series on Ansible . if you have not read part one and two  it can be found <a href="https://barriersec.com/category/linux-system-administration/introduction-to-ansible-part-1/">here .</a></p>
<p>Now lets quickly define our objectives.</p>
<ol>
<li>Remotely manage ( Start/Stop ) the JBoss server with the help of a custom SystemD initialization script which is in turn called using Ansible remotely.</li>
<li>Deploy a war file on JBoss application server which is placed at a remote machine.</li>
<li>Undeploy a war file on JBoss server remotely.</li>
</ol>
<p>As explained in our previous article, we can define static variables and defaults inside <strong>roles/webserver/</strong><strong>defaults/main.yml</strong> file. So lets define our defaults variables. place these in the specified file(on ansible server machine) :</p>
<p><strong><em>name : test</em></strong></p>
<p><strong><em>Username: DBuser</em></strong></p>
<p><strong><em>Password: DBPass</em></strong></p>
<p><strong><em>driver : &lt;drivername&gt;</em></strong></p>
<p><strong><em>connection_url : &lt;connection_url&gt;</em></strong></p>
<p><strong><em>pool_name: &lt;pool_name&gt;</em></strong></p>
<p><strong><em>JNDI_HOME: &lt;jndi_home&gt;</em></strong></p>
<p><strong><em>filter : &#8220;&lt;user-name&gt;{ { Username} }&lt;/user-name&gt;&#8221;</em></strong></p>
<p><strong><em>deployname: warfile.war</em></strong></p>
<p><strong><em>deploy_path: /path/to/deployment/scanner/path</em></strong></p>
<p><strong><em>DeploySrcTemp: /remotepath/to/deployment</em></strong></p>
<p>Now lets create a systemd service to control Jboss service. let us name it as   <strong>JbossControl.service </strong>with the following content.for tutorial on systemD refer my previous article :</p>
<p>&nbsp;</p>
<p><em><strong>[unit]</strong></em></p>
<p><em><strong>Description= Jboss Application server control script</strong></em></p>
<p><em><strong>After = network.target</strong></em></p>
<p><em><strong>[Service]</strong></em></p>
<p><em><strong>Type=idle</strong></em></p>
<p><em><strong>ExecStart=/path/to/jboss/bin/standalone.sh</strong></em></p>
<p><em><strong>ExecStop=/path/to/jboss/bin/jboss-cli.sh &#8211;connect command=:shutdown</strong></em></p>
<p><em><strong>TimeoutStartSec=400</strong></em></p>
<p><em><strong>TimeoutStopSec=400</strong></em></p>
<p><em><strong>[install]</strong></em></p>
<p><em><strong>WantedBy=multi-user.target</strong></em></p>
<p>save the file on remote machine and move it to <strong>roles/webserver/templates/ JbossControl.service.</strong></p>
<p>Now we have required resources which are required for managing a Jboss app server remotely.</p>
<p>Now on our ansible server machine, we can update our <strong>roles/webserver/tasks/main.yml </strong>file with following content.</p>
<p><strong> &#8212;</strong></p>
<p><strong> &#8211; name: copy jboss service file to systemd folder</strong></p>
<p><strong>   copy:</strong></p>
<p><strong>     src : &#8220;/path/to/ansible/roles/server/templates/JbossControl.service&#8221;</strong></p>
<p><strong>    dest: /etc/systemd/system/jbossControl.service</strong></p>
<p><strong>tags: [copyService]</strong></p>
<p>&nbsp;</p>
<p><strong> &#8211; name: start JBoss service</strong></p>
<p><strong>     systemd:</strong></p>
<p><strong>          state: started</strong></p>
<p><strong>          name: jbossControl</strong></p>
<p><strong>    tags: [StartJboss]</strong></p>
<p>&nbsp;</p>
<p><strong> &#8211; name: stop JBoss service</strong></p>
<p><strong>     systemd:</strong></p>
<p><strong>          state: stopped</strong></p>
<p><strong>          name: jbossControl</strong></p>
<p><strong>    tags: [StopJboss]</strong></p>
<p>&nbsp;</p>
<p>As we see in the tasks file, we have  used <strong>systemd module of ansible</strong> to invoke <strong>systemd services and targets</strong> . We have also utilized<strong> copy module</strong> to copy files from one location to another on remote system .now we can create a play.yml in the project root directory. with the following content:</p>
<p><strong> -hosts : RemoteMachines</strong></p>
<p><strong>  sudo : yes</strong></p>
<p><strong>  roles:</strong></p>
<p><strong>   &#8211; webserver </strong></p>
<p>now we can invoke this playbook to start jboss/stop jboss on remote machine as follows :</p>
<p>to start Jboss application server on remote machines defined in <strong>RemoteMachines</strong> file :</p>
<blockquote><p><strong>&gt; ansible-playbook play.yml &#8211;tags &#8220;copyService,StartJboss&#8221;</strong></p></blockquote>
<p>to stop Jboss application server on remote machines defined in <strong>RemoteMachines</strong> file :</p>
<p><strong>&gt; ansible-playbook play.yml &#8211;tags &#8220;StopJboss&#8221;</strong></p>
<p>here , tags attribute while calling the playbook helps us to specify which services to run from the role. if we do not specify the tags, every task on the specified role runs and returns the result.</p>
<p>We have successfully completed the first objective of managing the remote JBoss application server! In the next tutorial we will see how to deploy and un deploy the war file remotely which also in turn involves managing data sources and config files. Stay Tuned !</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/introduction-to-ansible-part-3/">Introduction to Ansible Part 3</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
