<?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>automation Archives - ServerStadium</title>
	<atom:link href="https://serverstadium.com/knowledge-base/tag/automation/feed/" rel="self" type="application/rss+xml" />
	<link>https://serverstadium.com/knowledge-base/tag/automation/</link>
	<description>Public Cloud Solution by ServerStadium</description>
	<lastBuildDate>Thu, 04 Jan 2024 23:28:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>

<image>
	<url>https://serverstadium.com/wp-content/uploads/2023/04/cropped-favicon-1-32x32.png</url>
	<title>automation Archives - ServerStadium</title>
	<link>https://serverstadium.com/knowledge-base/tag/automation/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Automating Server Security Audits with Custom Scripts</title>
		<link>https://serverstadium.com/knowledge-base/automating-server-security-audits-with-custom-scripts/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 04 Jan 2024 23:28:30 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11851</guid>

					<description><![CDATA[<p>Introduction Regular security audits are crucial for maintaining the integrity and safety of server environments. By automating these audits on ServerStadium’s infrastructure (VM Pricing, Dedicated Servers), you can continuously monitor and enhance your server&#8217;s security posture. Prerequisites A ServerStadium VM or dedicated server (VM Pricing, Dedicated Servers). Basic knowledge of shell scripting and Linux security.&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/automating-server-security-audits-with-custom-scripts/">Automating Server Security Audits with Custom Scripts</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Regular security audits are crucial for maintaining the integrity and safety of server environments. By automating these audits on ServerStadium’s infrastructure (<a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">VM Pricing</a>, <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Dedicated Servers</a>), you can continuously monitor and enhance your server&#8217;s security posture.</p>
<h3>Prerequisites</h3>
<ul>
<li>A ServerStadium VM or dedicated server (<a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">VM Pricing</a>, <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Dedicated Servers</a>).</li>
<li>Basic knowledge of shell scripting and Linux security.</li>
<li>Access to the server with necessary permissions.</li>
</ul>
<h3>Step 1: Set Up Your ServerStadium Environment</h3>
<ol>
<li><strong>Choose a Server</strong>: Opt for a ServerStadium server suitable for hosting your security scripts and storing audit logs.</li>
<li><strong>Server Setup</strong>:
<div class="shortcode-code">
<p> sudo apt update<br />
sudo apt upgrade </p></div></li>
</ol>
<h3>Step 2: Identify Key Security Metrics</h3>
<ol>
<li><strong>Define Audit Criteria</strong>:
<p>Determine the specific aspects of server security you want to audit, such as user account management, firewall settings, and file permissions.</li>
</ol>
<h3>Step 3: Write Custom Security Audit Scripts</h3>
<ol>
<li><strong>Develop Audit Scripts</strong>:
<p>Write scripts that check various security parameters. Here’s an example script to check for unauthorized SSH access attempts:</p>
<div class="shortcode-code">
<p> #!/bin/bash echo &quot;Checking for Unauthorized SSH Access Attempts&quot; grep &quot;Failed password&quot; /var/log/auth.log | less </p></div></li>
<li><strong>Script for Checking User Accounts</strong>:
<p>A script to list all user accounts and their last login time:</p>
<div class="shortcode-code">
<p> #!/bin/bash echo &quot;Listing All User Accounts and Their Last Login&quot; lastlog </p></div></li>
</ol>
<h3>Step 4: Automate Script Execution</h3>
<ol>
<li><strong>Schedule Cron Jobs</strong>:
<p>Use cron to schedule your scripts to run at regular intervals.</p>
<div class="shortcode-code">
<p> crontab -e </p></div>
<p>Add a line to execute your script, e.g., every day at midnight</p>
<div class="shortcode-code">
<p> 0 0 * * * /path/to/your/script.sh </p></div></li>
</ol>
<h3>Step 5: Monitor and Review Audit Logs</h3>
<ol>
<li><strong>Review Audit Results</strong>:
<p>Regularly check the output of your scripts. Consider setting up email alerts for critical issues.</li>
</ol>
<h3>Conclusion</h3>
<p>Automated security audits using custom scripts on your ServerStadium server are a proactive measure to ensure ongoing security compliance and to quickly identify potential vulnerabilities. For additional support or resources, visit our <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">knowledge base</a> or contact our support team.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/automating-server-security-audits-with-custom-scripts/">Automating Server Security Audits with Custom Scripts</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting Up Rundeck 5 for Job Scheduling and Runbook Automation</title>
		<link>https://serverstadium.com/knowledge-base/setting-up-rundeck-5-for-job-scheduling-and-runbook-automation/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 04 Jan 2024 22:54:06 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11842</guid>

					<description><![CDATA[<p>Introduction Rundeck 5, with its advanced features for automation and job scheduling, is an excellent tool for managing complex tasks efficiently on ServerStadium&#8217;s infrastructure (VM Pricing, Dedicated Servers). Prerequisites A ServerStadium VM or dedicated server (VM Pricing, Dedicated Servers). Basic knowledge of Linux server administration. Step 1: Select and Prepare Your ServerStadium Server Choose a&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-rundeck-5-for-job-scheduling-and-runbook-automation/">Setting Up Rundeck 5 for Job Scheduling and Runbook Automation</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Rundeck 5, with its advanced features for automation and job scheduling, is an excellent tool for managing complex tasks efficiently on ServerStadium&#8217;s infrastructure (<a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">VM Pricing</a>, <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Dedicated Servers</a>).</p>
<h3>Prerequisites</h3>
<ul>
<li>A ServerStadium VM or dedicated server (<a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">VM Pricing</a>, <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">Dedicated Servers</a>).</li>
<li>Basic knowledge of Linux server administration.</li>
</ul>
<h3>Step 1: Select and Prepare Your ServerStadium Server</h3>
<ol>
<li><strong>Choose a Server</strong>: Opt for a ServerStadium server suitable for your workload.</li>
<li><strong>Server Setup</strong>:
<div class="shortcode-code">
<p> sudo apt update<br />
sudo apt upgrade </p></div></li>
</ol>
<h3>Step 2: Install Java</h3>
<p>Rundeck 5 requires Java:</p>
<ol>
<li><strong>Install Java</strong>:
<div class="shortcode-code">
<p> sudo apt-get install openjdk-11-jre-headless </p></div></li>
</ol>
<h3>Step 3: Install Rundeck 5</h3>
<ol>
<li><strong>Add Rundeck Repository</strong>:
<p>Use the script provided by PackageCloud to add the Rundeck repository:</p>
<div class="shortcode-code">
<p> curl -s https://packagecloud.io/install/repositories/pagerduty/rundeck/script.deb.sh?any=true | sudo bash </p></div></li>
<li><strong>Install Rundeck 5</strong>:
<p>Now install the specific version of Rundeck:</p>
<div class="shortcode-code">
<p> sudo apt-get install rundeck=5.0.0.20231216-1 </p></div></li>
</ol>
<h3>Step 4: Configure Rundeck</h3>
<ol>
<li><strong>Configure Rundeck</strong>:
<p>Edit the Rundeck configuration files as needed.</p>
<div class="shortcode-code">
<p> sudo nano /etc/rundeck/rundeck-config.properties </p></div></li>
<li><strong>Start Rundeck Service</strong>:
<div class="shortcode-code">
<p> sudo systemctl start rundeckd<br />
sudo systemctl enable rundeckd </p></div></li>
</ol>
<h3>Step 5: Accessing Rundeck</h3>
<ol>
<li><strong>Access Rundeck Web Interface</strong>:
<p>Navigate to <code>http://your_server_ip:4440</code> in a browser. The default login is admin/admin.</li>
</ol>
<h3>Step 6: Create and Schedule Jobs</h3>
<ol>
<li><strong>Create a Simple Job</strong>:
<p>Example &#8211; Create a job to check disk space:</p>
<ul>
<li>Go to the Rundeck dashboard.</li>
<li>Navigate to &#8216;Jobs&#8217; and click on &#8216;Create a New Job&#8217;.</li>
<li>Name the job (e.g., &#8220;Check Disk Space&#8221;).</li>
<li>In the &#8216;Workflow&#8217; section, add a step.</li>
<li>Choose &#8216;Command&#8217; as the step type.</li>
<li>Enter the command: <code>df -h</code>.</li>
<li>Save the job.</li>
</ul>
</li>
<li><strong>Schedule the Job</strong>:
<ul>
<li>In the job settings, go to the &#8216;Schedule&#8217; tab.</li>
<li>Choose a schedule, like &#8220;Run every day at midnight&#8221;.</li>
<li>Save the schedule settings.</li>
</ul>
</li>
</ol>
<h3>Step 7: Manage Runbooks and Workflows</h3>
<ol>
<li><strong>Automate a Cleanup Workflow</strong>:
<p>Example &#8211; Create a workflow to clean temporary files:</p>
<ul>
<li>Create a new job named &#8220;Cleanup Temp Files&#8221;.</li>
<li>Add a step with the command: <code>rm -rf /tmp/*</code>.</li>
<li>Optionally, add more steps for additional cleanup tasks.</li>
<li>Save the job.</li>
</ul>
</li>
<li><strong>Documenting a Procedure</strong>:
<ul>
<li>In the job description or notes, document the purpose and procedure of the job.</li>
<li>Provide clear instructions or notes on what the job does and any important considerations.</li>
</ul>
</li>
</ol>
<h3>Conclusion</h3>
<p>Rundeck on ServerStadium provides a comprehensive solution for job scheduling and runbook automation, streamlining IT operations and enhancing efficiency. For additional support or resources, visit our <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">knowledge base</a> or contact our support team.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/setting-up-rundeck-5-for-job-scheduling-and-runbook-automation/">Setting Up Rundeck 5 for Job Scheduling and Runbook Automation</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automating Tasks on Ubuntu with Cron Jobs: A Comprehensive Guide with ServerStadium</title>
		<link>https://serverstadium.com/knowledge-base/automating-tasks-with-cron-on-ubuntu/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Mon, 18 Sep 2023 19:45:50 +0000</pubDate>
				<guid isPermaLink="false">https://serverstadium.com/?post_type=epkb_post_type_1&#038;p=11736</guid>

					<description><![CDATA[<p>In the dynamic world of server management, efficiency is key. One of the most powerful tools at an administrator&#8217;s disposal is the ability to automate tasks. Enter cron jobs, a scheduler for Unix-like operating systems, including Ubuntu. With ServerStadium&#8217;s robust infrastructure, setting up and managing cron jobs becomes a breeze. What are Cron Jobs? Cron&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/automating-tasks-with-cron-on-ubuntu/">Automating Tasks on Ubuntu with Cron Jobs: A Comprehensive Guide with ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the dynamic world of server management, efficiency is key. One of the most powerful tools at an administrator&#8217;s disposal is the ability to automate tasks. Enter cron jobs, a scheduler for Unix-like operating systems, including Ubuntu. With ServerStadium&#8217;s robust infrastructure, setting up and managing cron jobs becomes a breeze.</p>
<p><strong>What are Cron Jobs?</strong></p>
<p>Cron jobs are scheduled tasks that run automatically at specified intervals on your server. Whether it&#8217;s daily backups, regular system updates, or any repetitive tasks, cron jobs ensure your server operates smoothly without manual intervention.</p>
<p><strong>Setting Up Cron on Ubuntu with ServerStadium</strong></p>
<ol>
<li><strong>Installation</strong>: Most Ubuntu servers come with cron pre-installed. If not, install it with:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-sql">sudo apt<span class="hljs-operator">-</span><span class="hljs-keyword">get</span> <span class="hljs-keyword">update</span><br />
sudo apt<span class="hljs-operator">-</span><span class="hljs-keyword">get</span> install cron<br />
</code></div>
</div>
</li>
<li><strong>Configuration</strong>: Access the cron table to set up tasks:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs">crontab -e<br />
</code></div>
</div>
<p>This opens the user-specific cron table where you can add tasks.</li>
<li><strong>Scheduling Tasks</strong>: Cron uses a specific format to schedule tasks. For instance, to run a backup script daily at midnight, you&#8217;d add:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-javascript"><span class="hljs-number">0</span> <span class="hljs-number">0</span> * * * <span class="hljs-regexp">/path/</span>to/backup_script.<span class="hljs-property">sh</span><br />
</code></div>
</div>
<p>Familiarize yourself with the cron time format to schedule tasks as needed.</li>
</ol>
<p><strong>Best Practices for Cron Jobs on ServerStadium</strong></p>
<ol>
<li><strong>Logging</strong>: Ensure your cron jobs log outputs, especially errors. This helps in troubleshooting. For example:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-javascript"><span class="hljs-number">0</span> <span class="hljs-number">0</span> * * * <span class="hljs-regexp">/path/</span>to/script.<span class="hljs-property">sh</span> &gt;&gt; <span class="hljs-regexp">/path/</span>to/logfile.<span class="hljs-property">log</span> <span class="hljs-number">2</span>&gt;&amp;<span class="hljs-number">1</span><br />
</code></div>
</div>
</li>
<li><strong>Backup</strong>: Before making changes to the crontab, consider backing it up using:
<div class="bg-black rounded-md mb-4">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs">crontab -l &gt; backup_crontab.txt </code></div>
</div>
</li>
<li><strong>Security</strong>: Ensure scripts called by cron jobs have appropriate permissions and are not accessible by unauthorized users.</li>
</ol>
<p><strong>Conclusion</strong> Cron jobs offer a world of automation possibilities, ensuring your server operations are efficient and timely. With <a href="https://serverstadium.com/dedicated-server/" target="_new" rel="noopener">ServerStadium&#8217;s dedicated servers</a> and <a href="https://serverstadium.com/pricing/" target="_new" rel="noopener">cloud VM solutions</a>, you have the perfect environment to harness the power of cron on Ubuntu.</p>
<p>Looking for more insights and guides on server management? Dive into <a href="https://serverstadium.com/knowledge-base/" target="_new" rel="noopener">ServerStadium&#8217;s knowledge base</a> for expert articles and tips.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/automating-tasks-with-cron-on-ubuntu/">Automating Tasks on Ubuntu with Cron Jobs: A Comprehensive Guide with ServerStadium</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Classes: Post Installation on Ansible</title>
		<link>https://serverstadium.com/knowledge-base/classes-post-installation-on-ansible/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Fri, 26 Feb 2021 02:57:19 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=624</guid>

					<description><![CDATA[<p>Managing many servers is not an easy job; we need to plan and create a good and manageable Ansible Playbook to implement Ansible properly. Since then, we all agree that it is hard to manage a lot of servers at once. For example, you have installed 50 VMs/Servers with fresh OS and need to add&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/classes-post-installation-on-ansible/">Classes: Post Installation on Ansible</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Managing many servers is not an easy job; we need to plan and create a good and manageable Ansible Playbook to implement Ansible properly.</p>



<p class="wp-block-paragraph">Since then, we all agree that it is hard to manage a lot of servers at once. For example, you have installed 50 VMs/Servers with fresh OS and need to add some users to it.</p>



<p class="wp-block-paragraph">Thus, In this class, we will learn how to add some users to the servers using Ansible Playbook.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">How to Add users using Ansible Playbook</h2>



<p class="wp-block-paragraph">First, create a folder called ansible_try</p>



<p class="wp-block-paragraph">Under folder ansible_try, create files for inventory and YML master playbook.</p>



<p class="wp-block-paragraph">For the inventory file, please fill in the lists of the IP address server.</p>



<pre class="wp-block-preformatted"><sup><code>[allserver]</code></sup> <sup><code>192.168.20.183</code></sup> <sup><code>192.168.20.184</code></sup></pre>



<p class="wp-block-paragraph">Then, create a YML file for the master playbook</p>



<ul class="wp-block-list">
<li>usergroup.yml</li>
</ul>



<pre class="wp-block-preformatted"><code>   hosts: allservers</code> <code>gather_facts: false</code> <code>roles:</code> <code>- usergroup</code></pre>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<ul class="wp-block-list">
<li>after that, create 3 folders called tasks, files, and vars.</li>
</ul>



<ul class="wp-block-list">
<li>The tasks folder, will be filled with the Ansible automation code</li>
</ul>



<ul class="wp-block-list">
<li>Files folder will be filled with the SSH_Key_Pub and sudoers config file</li>
</ul>



<ul class="wp-block-list">
<li>The Vars folder will be filled with variables files for Ansible automation code</li>
</ul>



<p class="wp-block-paragraph">Then, go to the Task folder and create a file as below:</p>



<p class="wp-block-paragraph">main.ym</p>
</div></div>



<p class="wp-block-paragraph">&nbsp;</p>
</div></div>



<pre class="wp-block-preformatted"><code>import_tasks: configureSudoers.yml</code> <code>import_tasks: configureUsers.yml</code> __________________________________________________</pre>



<p class="wp-block-paragraph">configureSudoers.yml</p>



<pre class="wp-block-preformatted"><code>name: Create Engineer Group</code> <code>group: name=engineer state=present</code> <code>ignore_errors: yes</code> <code>become: true</code> <code>tags:</code> <code>- sudoersgroup</code> <code>name: Engineer Group As Sudoers</code> <code>copy: src=sudoers.d/00-engineer.j2 dest=/etc/sudoers.d/00-engineer</code> <code>owner=root</code> <code>group=root</code> <code>mode=440</code> <code>backup=no</code> <code>ignore_errors: yes</code> <code>become: true</code> <code>tags:</code> <code>- sudoersgroup</code> _________________________________________________</pre>



<p class="wp-block-paragraph">configureUsers.yml</p>



<pre class="wp-block-preformatted"><br /><code>name: Manage Users SA</code><br /><code>user:</code><br /><code>name: "{{ item.key }}"</code><br /><code>state: "{{ item.value.state }}"</code><br /><code>groups: "{{ item.value.groups }}"</code><br /><code>shell: "{{ item.value.shell }}"</code><br /><code>with_dict: '{{users_sa}}'</code><br /><code>become: true</code><br /><code>tags:</code><br /><code>- usergroup</code><br /><br /><code>name: Manage User Keys SA</code><br /><code>authorized_key:</code><br /><code>user: "{{ item.key }}"</code><br /><code>state: present</code><br /><code>key: "{{ lookup('file', item.value.authkey) }}"</code><br /><code>with_dict: '{{users_sa}}'</code><br /><code>become: true</code><br /><code>tags:</code><br /><code>- usergroup</code><br /><br /><code>name: Remove inactive User</code><br /><code>user:</code><br /><code>name: "{{ item.key }}"</code><br /><code>state: "{{ item.value.state }}"</code><br /><code>remove: "{{ item.value.remove }}"</code><br /><code>with_dict: '{{ inactiveUsers }}'</code><br /><code>become: true</code><br /><code>tags:</code><br /><code>- usergroup</code><br /><code>- remove</code></pre>



<ul class="wp-block-list">
<li>After creating the task code, then go to the vars folder and create main.yml file</li>
</ul>



<pre class="wp-block-preformatted">main.yml<br /><br /><code>users_sa:<br />user1:<br />name: user1<br />state: present<br />groups: engineer<br />shell: /bin/bash<br />authkey: authkeys/user1.pub<br /><br />users_noc:<br />user2:<br />name: user2<br />state: present<br />groups: engineer<br />shell: /bin/bash<br />authkey: authkeys/user.pub</code><br /><br /><code>inactiveUsers:</code><br /><code>alfian:<br />state: absent<br />remove: yes<br /></code></pre>



<ul class="wp-block-list">
<li>Then, goes to the Files Folder and create two subfolders &#8220;authkeys&#8221; and &#8220;sudoers.d&#8221;</li>
<li>Under the folder &#8220;authkeys&#8221;, put the SSH_Key_Public according to it&#8217;s username, for example, user1.pub, user2.pub</li>
<li>Next, under the &#8220;sudoers.d&#8221;, put the jinja file about the sudoers file configuration that will be copied to the server as below
<ul>
<li>Create a file with name 00-engineer.j2</li>
<li>Fill with below sudoers configuration<br />&#8220;%engineer ALL=NOPASSWD: ALL&#8221;</li>
</ul>
</li>
</ul>



<ul class="wp-block-list">
<li>Back to the top of folder ansible_try and run this command</li>
</ul>



<pre class="wp-block-preformatted"><code>ansible-playbook -i inventory usergroup.yml -u ubunt</code>u</pre>



<ul class="wp-block-list">
<li>ansible-playbook is a command for running a playbook
<ul>
<li>-i is for variable inventory</li>
<li>-u is for the username used for SSH</li>
</ul>
</li>
</ul>



<ul class="wp-block-list">
<li>The Output will go like this</li>
</ul>



<pre class="wp-block-code"><code>PLAY [allserver] *************************************************************************************************************************************

TASK [usergroup : Create Engineer Group] *************************************************************************************************************
ok: [192.168.20.184]
ok: [192.168.20.183]

TASK [usergroup : Engineer Group As Sudoers] *********************************************************************************************************
changed: [192.168.20.183]
changed: [192.168.20.184]

TASK [usergroup : Manage Users SA] *******************************************************************************************************************
ok: [192.168.20.183] =&gt; (item={'key': 'user1', 'value': {'name': 'user1', 'state': 'present', 'groups': 'engineer', 'shell': '/bin/bash', 'authkey': 'authkeys/user1.pub'}})
ok: [192.168.20.184] =&gt; (item={'key': 'user1', 'value': {'name': 'user1', 'state': 'present', 'groups': 'engineer', 'shell': '/bin/bash', 'authkey': 'authkeys/user1.pub'}})
ok: [192.168.20.183] =&gt; (item={'key': 'user2', 'value': {'name': 'user2', 'state': 'present', 'groups': 'engineer', 'shell': '/bin/bash', 'authkey': 'authkeys/user2.pub'}})
ok: [192.168.20.184] =&gt; (item={'key': 'user2', 'value': {'name': 'user2', 'state': 'present', 'groups': 'engineer', 'shell': '/bin/bash', 'authkey': 'authkeys/user2.pub'}})

TASK [usergroup : Remove inactive User] **************************************************************************************************************
ok: [192.168.20.183] =&gt; (item={'key': 'alfian', 'value': {'name': 'alfian', 'state': 'absent', 'remove': True}})
ok: [192.168.20.184] =&gt; (item={'key': 'alfian', 'value': {'name': 'alfian', 'state': 'absent', 'remove': True}})

PLAY RECAP *******************************************************************************************************************************************
192.168.20.183             : ok=5    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
192.168.20.184             : ok=5    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
</code></pre>



<ul class="wp-block-list">
<li>If you want just to send a command to get the output, like checking the OS version, just execute this command</li>
</ul>



<pre class="wp-block-preformatted"><br /><code>ansible allserver -m shell -a "lsb_release -a" -i inventory -u ubuntu</code></pre>



<ul class="wp-block-list">
<li>The output will go like this</li>
</ul>



<pre class="wp-block-code"><code>192.168.20.184 | CHANGED | rc=0 &gt;&gt;
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:        16.04
Codename:       xenialNo LSB modules are available.
192.168.20.183 | CHANGED | rc=0 &gt;&gt;
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:        16.04
Codename:       xenialNo LSB modules are available.
</code></pre>



<ul class="wp-block-list">
<li>So with this Ansible command, you don&#8217;t need to sign in to every single server to check the OS version, and it will make your action faster, especially if the server you manage is quite a large scale.</li>
</ul>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Summary</h2>



<p class="wp-block-paragraph">To manage many servers, you need to learn how to run Ansible post the installation. Eager to know more? Visit our <a href="https://ServerStadium.com/knowledge-base/" target="_blank" rel="noreferrer noopener">site.</a></p>
<p>The post <a href="https://serverstadium.com/knowledge-base/classes-post-installation-on-ansible/">Classes: Post Installation on Ansible</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Classes: Install and Configure Ansible</title>
		<link>https://serverstadium.com/knowledge-base/install-and-configure-ansible/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 07:09:13 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=626</guid>

					<description><![CDATA[<p>Previously we have introduced Ansible. Therefore, this article will discuss how to install and configure Ansible on Linux. In short, Ansible is an agentless automation tool that uses SSH and Python to manage remote servers. It does not need a database server or run as a daemon or service. You can easily install it on&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/install-and-configure-ansible/">Classes: Install and Configure Ansible</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Previously we have introduced Ansible. Therefore, this article will discuss how to install and configure Ansible on Linux.</p>



<p class="wp-block-paragraph">In short, <a href="https://kb.iu.edu/d/aaik">Ansible</a> is an agentless automation tool that uses SSH and Python to manage remote servers. It does not need a database server or run as a daemon or service. You can easily install it on a server or a laptop, and that’s it; after that, you can start using Ansible to manage an entire fleet of remote servers from your laptop.</p>



<p class="wp-block-paragraph">When Ansible manages remote <a href="https://ServerStadium.com/knowledge-base/deploying-a-virtual-machine-in-Server-Stadium/">machines,</a> it does not leave software installed or running on them. So there’s no real question about how to upgrade Ansible when moving to a new version. In addition, currently, Ansible can be run from any machine with Python 2 (version 2.7) or Python 3 (versions 3.5 and higher) installed.</p>



<p class="wp-block-paragraph">Ansible only needs python2 (version 2.7) or python3 (version 3.5 and higher) installed on the remote servers to manage them, and that’s it; no need for other software or service, which is why it’s called agentless.</p>



<p class="wp-block-paragraph">Therefore, to understand better, please closely examine how to install and configure Ansible on Linux below.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Installing Ansible on Linux</h2>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<ul class="wp-block-list">
<li>On Fedora:</li>
</ul>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<pre class="wp-block-preformatted"><code>$ sudo dnf install ansible </code></pre>
</div></div>
</div></div>



<ul class="wp-block-list">
<li>On RHEL and CentOS:</li>
</ul>



<pre class="wp-block-preformatted"><code>$ sudo yum install ansible</code></pre>



<ul class="wp-block-list">
<li>On Ubuntu:</li>
</ul>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<pre class="wp-block-preformatted"><code>$ sudo apt update </code><br /><code>$ sudo apt install software-properties-common </code><br /><code>$ sudo apt-add-repository --yes --update ppa:ansible/ansible </code><br /><code>$ sudo apt install ansible</code></pre>
</div></div>



<p class="wp-block-paragraph">Once you have installed Ansible, run the command below to make sure that Ansible is installed properly.</p>



<pre class="wp-block-preformatted"><code>$ ansible --version</code></pre>



<p class="wp-block-paragraph">Then, you will see the output would be something like the below.</p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<pre class="wp-block-preformatted"><br /><code>ansible 2.9.16<br />config file = /etc/ansible/ansible.cfg<br />configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']<br />ansible python module location = /usr/lib/python2.7/dist-packages/ansible<br />executable location = /usr/bin/ansible<br />python version = 2.7.17 (default, Sep 30 2020, 13:38:04) [GCC 7.5.0]</code></pre>
</div></div>



<p class="wp-block-paragraph">Due to the output, we could see that Ansible has a configuration that can be optimized as your need at /etc/ansible/ansible.cfg<br />By default, the configuration is enough for you to make an Ansible role as well as Ansible read the ssh keys form ~/.ssh/id_rsa. Although It depends on what users are logging in, you still can optimize that in the [ssh_connection] section. Not only can you make it more fun by optimizing the color of your ansible output, but you can also change it in the [colors] section as well.</p>



<p class="wp-block-paragraph">As I mentioned in the previous classes, you need to follow the Ansible hierarchy to make Ansible run well. By default, ansible already created files on /etc/ansible path for inventory and roles, but you can move it to your desired path.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Ansible hierarchy</h2>



<ul class="wp-block-list">
<li>Inventory: this file is for the inventory list of your server. You can group it with server functions or roles.<br />Example format:<br />[allserver]<br />192.168.20.1<br />192.168.20.2<br />192.168.20.3<br />192.168.20.4<br /><br />[lb_server]<br />192.168.20.1<br />192.168.20.2</li>
<li>Group_vars: here we assign variables to particular groups<br />This will be applied to all servers when Ansible runs<br />Example format:<br />ntpserverip: ntp.domain.com<br />rsyslog_version: &#8216;*&#8217;</li>
<li>Host_vars: if systems need specific variables, put them here.<br />This will be applied to some servers that are defined in this path.<br />Thus, the file should be named with the IP listed in the inventory<br />Example format:<br />host_name: lb-vm1<br />host_domain: domain.com<br />full_host_name: &#8220;{{ host_name }}.{{ host_domain }}&#8221;<br />ip_address: 192.168.20.1</li>
</ul>



<ul class="wp-block-list">
<li>site.yml: master playbook<br />This file will be called in the first time when running ansible-playbook<br />In this file, you need to define what role and which server will be executed. Then, you need to save the file in yml format.<br />Example format:<br />hosts: allserver<br />gather_facts: false<br />roles:<br />&#8211; usergroup</li>
</ul>



<ul class="wp-block-list">
<li>roles: list of roles and scripts that will be executed.</li>
</ul>



<p class="wp-block-paragraph">So, do you want to know how to use Ansible?<br />Please follow this link.</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/install-and-configure-ansible/">Classes: Install and Configure Ansible</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Classes: Introduction to Ansible for a robust Configuration Management</title>
		<link>https://serverstadium.com/knowledge-base/introduction-to-ansible-for-a-robust-configuration-management/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Tue, 23 Feb 2021 11:52:52 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=628</guid>

					<description><![CDATA[<p>Do you need robust configuration management? If you manually manage many servers with many configurations, then you know how difficult it is. This is where Ansible can help you to have better server management and configuration standardization without too much hassle. What is Ansible? Ansible is an open-source IT Configuration Management, Deployment &#38; Orchestration tool.&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/introduction-to-ansible-for-a-robust-configuration-management/">Classes: Introduction to Ansible for a robust Configuration Management</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Do you need robust configuration management? If you manually manage many servers with many configurations, then you know how difficult it is. This is where Ansible can help you to have better server management and configuration standardization without too much hassle.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>What is Ansible?</strong></h2>



<ul class="wp-block-list">
<li>Ansible is an open-source IT Configuration Management, Deployment &amp; Orchestration tool.</li>
<li>It aims to provide large productivity gains to various automation challenges.<br />For example, you are going to config SMTP servers or collect logs from SMTP servers.</li>
<li>This tool is very simple to use but powerful enough to automate complex application environments.</li>
<li>Ansible is an automation tool that provides a way to define infrastructure as code.</li>
<li>Infrastructure as code (IAC) means managing infrastructure by writing code rather than using manual processes.</li>
<li>You don’t need to know the commands to accomplish a specific task.<br />For example, when adding a new user on Linux OS. Normally, you need to run more than two commands to add the new user.</li>
<li>In Ansible, you simply need to specify what state you want the system to be in, and then Ansible will take care of it. <br />(In case of adding a user, state can be &#8220;present&#8221; or &#8220;absent&#8221;)</li>
<li>For example,
<ul>
<li>Task for create new user<br />&#8211; name: Manage Users  <br />user:    <br />name: user1    <br />state: present  <br />groups: engineer    <br />shell: /bin/bash    <br />become: true  <br />tags:    &#8211; usergroup</li>
</ul>
</li>
</ul>



<p class="wp-block-paragraph">Ansible connects via SSH to remote hosts listed on inventory files such as /etc/ansible/hosts. You can do a simple command by using the Ansible adhoc command. For example, to get a date from a server, you can do it like “ansible –m command SERVER date”.</p>



<p class="wp-block-paragraph">You can also do a complete setup on a server, like installing apps and configuring them on a server using Ansible Playbook. Playbook is a template for which “Infrastructure as a Code” term refers to a Code.</p>



<p class="wp-block-paragraph">Playbook will have modules, inventory, and tasks. Since Playbook is a template, we can use it as a standard centralized configuration for all the server provisioning. Also, we can share the templates and modify them as needed.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Terminologies</h2>



<p class="wp-block-paragraph" id="6edf">Generally, Ansible uses these terminologies below:</p>



<ol class="wp-block-list">
<li>Controller Machine: Machine to install Ansible</li>
<li>Inventory: detailed info regarding servers to be managed</li>
<li>Playbook: Automation is defined using tasks defined in YAML format</li>
<li>Task: Procedure to be executed</li>
<li>Module: Predefined command execute directly on remote hosts</li>
<li>Play: Execution of a playbook</li>
<li>Role: a Pre-defined way for organizing playbooks</li>
<li>Handlers: Tasks with unique names. Another task will execute it if there is any notification. <br /><br />(For an example of the configuration, please visit &#8220;Classes: Install and Configure Ansible&#8221; and &#8220;Classes: Post Installation&#8221;)</li>
</ol>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading"><strong>Advantages of Ansible</strong> for Configuration Management</h2>



<ul class="wp-block-list">
<li>Ansible is an open-source tool.</li>
<li>Ansible’s playbooks do not require special coding skills.</li>
<li>It also allows you to model even highly complex IT workflows.<br />For example, you need to add a repository based on the OS version.</li>
<li>You do not need to install any agent on the target systems you want to automate.</li>
<li>You do not need to set up a separate management structure like puppet.</li>
<li>Since you don’t have to install any extra software, your server has more room for application resources.</li>
<li>Ansible is simple, reliable, and consistent for configuration management.</li>
<li>Secure and consistent<br />Because Ansible only uses SSH and Python on the managed nodes, it ensures safety and security.</li>
<li>Reliable<br />An Ansible playbook can be idempotent when written carefully. This prevents unexpected side effects on the managed systems.<br />An operation is idempotent if the result of performing it once is exactly the same as the result of performing it repeatedly without any intervening actions (denoting an element of a set that is unchanged).</li>
</ul>



<p class="wp-block-paragraph">Lastly, if you want to know how to install and configure Ansible, you can find out by reading <a href="https://ServerStadium.com/knowledge-base/install-and-configure-ansible/" target="_blank" rel="noreferrer noopener">this article.</a></p>
<p>The post <a href="https://serverstadium.com/knowledge-base/introduction-to-ansible-for-a-robust-configuration-management/">Classes: Introduction to Ansible for a robust Configuration Management</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
