{"id":56525,"date":"2023-01-27T14:18:30","date_gmt":"2023-01-27T08:48:30","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=56525"},"modified":"2023-01-27T14:18:30","modified_gmt":"2023-01-27T08:48:30","slug":"foreman-and-puppet-the-og-duo-for-it-automation","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/foreman-and-puppet-the-og-duo-for-it-automation\/","title":{"rendered":"Foreman and Puppet: The OG Duo for IT Automation"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56570 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-2023-01-27-141555.png\" alt=\"\" width=\"367\" height=\"244\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-2023-01-27-141555.png 367w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-2023-01-27-141555-300x199.png 300w\" sizes=\"(max-width: 367px) 100vw, 367px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Foreman is a powerful open-source tool that helps in managing the infrastructure, including the provisioning, configuration, and monitoring of servers. Puppet is a well-known configuration management tool that can be used in conjunction with Foreman to automate the configuration of servers. This blog post will cover the latest installation and integration of Foreman with Puppet on Ubuntu 20.04.<\/span><\/p>\n<p><strong>Prerequisites<\/strong><\/p>\n<ul>\n<li>A server running Ubuntu 20.04 or later<\/li>\n<li>A server running Puppet 6 or later<\/li>\n<li>A domain name or a static IP address for the Foreman server<\/li>\n<li>A DNS server configured with a DNS A record that resolves the hostname of the Foreman server to its IP address, or a hosts file entry on the client systems that will be managed by Foreman.<\/li>\n<\/ul>\n<p><em>Please note that you will need to open the following TCP ports to access your server:<\/em><\/p>\n<ul>\n<li>TCP port 80\u200a\u2014\u200afor the configuration deployment service.<\/li>\n<li>TCP port 443\u200a\u2014\u200ato access the Foreman control panel.<\/li>\n<li>TCP port 8140\u200a\u2014\u200afor Puppet Agent to work.<\/li>\n<li>TCP port 5648\u200a\u2014\u200afor client and Smart Proxy operation.<\/li>\n<li>TCP port 9090\u200a\u2014\u200afor communication with Smart Proxy.<\/li>\n<\/ul>\n<h2>Installation of Foreman<\/h2>\n<p><strong><span style=\"text-decoration: underline;\">Step 1<\/span><\/strong>: Add the Foreman repository to your system by running the following command:<\/p>\n<pre>echo \"deb http:\/\/deb.theforeman.org\/ focal 3.4\" | sudo tee \/etc\/apt\/sources.list.d\/foreman.list\r\necho \"deb http:\/\/deb.theforeman.org\/ plugins 3.4\" | sudo tee -a \/etc\/apt\/sources.list.d\/foreman.list\r\nOR<\/pre>\n<p><strong><span style=\"text-decoration: underline;\">Step 2<\/span><\/strong>: Import the repository GPG key by running the following command:<\/p>\n<pre>wget -q https:\/\/deb.theforeman.org\/pubkey.gpg -O- | sudo apt-key add -<\/pre>\n<p>OR<\/p>\n<pre>sudo wget https:\/\/deb.theforeman.org\/foreman.asc -O \/etc\/apt\/trusted.gpg.d\/foreman.asc<\/pre>\n<p><strong><span style=\"text-decoration: underline;\">Step 3<\/span><\/strong>: Update the package list and install the Foreman package by running the following command:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt install foreman-installer<\/pre>\n<p><strong><span style=\"text-decoration: underline;\">Step 4<\/span><\/strong>: Run the installer with the following command:<\/p>\n<pre>sudo foreman-installer<\/pre>\n<p><strong><span style=\"text-decoration: underline;\">Step 5<\/span><\/strong>: The installer will guide you through the installation process, which includes configuring the database, web server, and other components. Make sure to configure the correct settings for your environment, such as the hostname, database settings and the SSL settings.<\/p>\n<p>In the next step, you will receive the username and password of an account with Foreman administrator rights.<\/p>\n<p>After it completes, the installer will print some details about where to find Foreman and the Smart Proxy. Output should be similar to this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56566 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-2023-01-27-140945.png\" alt=\"\" width=\"705\" height=\"97\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-2023-01-27-140945.png 705w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-2023-01-27-140945-300x41.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-2023-01-27-140945-624x86.png 624w\" sizes=\"(max-width: 705px) 100vw, 705px\" \/><\/p>\n<h2>\n<strong>Installation of Puppet<\/strong><\/h2>\n<p><strong><span style=\"text-decoration: underline;\">Step 1<\/span><\/strong>: Add the Puppet repository to your system by running the following command:<\/p>\n<pre>wget https:\/\/apt.puppetlabs.com\/puppet6-release-focal.deb\r\nsudo dpkg -i puppet6-release-focal.deb<\/pre>\n<p><strong><span style=\"text-decoration: underline;\">Step 2<\/span><\/strong>: Update the package list and install the Puppet package by running the following command:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt install puppet-agent<\/pre>\n<h2><strong>Integration of Foreman with Puppet<\/strong><\/h2>\n<p><strong><span style=\"text-decoration: underline;\">Step 1<\/span><\/strong>: Install the Foreman and Puppet modules by running the following command:<\/p>\n<pre>sudo apt install -y ruby-foreman-puppet<\/pre>\n<p>This command will install the necessary modules that allow Foreman to communicate with Puppet.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Step 2<\/span><\/strong>: Configure Puppet to use Foreman as its certificate authority by adding the following lines to the puppet.conf file:<\/p>\n<pre>cat &gt;&gt; \/etc\/puppetlabs\/puppet\/puppet.conf &lt;&lt; EOL\r\n[main]\r\nserver = foreman.example.com\r\nca_server = foreman.example.com\r\nenvironment = production\r\nruninterval = 1800\r\nconfigtimeout = 600\r\ncertname = foreman.example.com\r\nEOL<\/pre>\n<p>This step will configure the puppet agent to use the Foreman server as the certificate authority and set the environment, run interval and config timeout accordingly.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Step 3<\/span><\/strong>: Configure Foreman to use the Puppet CA by running the following command:<\/p>\n<pre>sudo foreman-rake puppet:ca:create\r\nsudo foreman-rake puppet:ca:import<\/pre>\n<p>This step will create and import the Puppet CA into Foreman, allowing it to manage the certificate signing process.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Step 4<\/span><\/strong>: Import the Puppet classes into Foreman by running the following command:<\/p>\n<pre>sudo puppet class list --all | sudo foreman-rake puppet:import:puppet_classes<\/pre>\n<p>This command will import all available Puppet classes into Foreman, allowing you to manage them through the Foreman web interface.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Step 5<\/span><\/strong>: Register your Puppet agent nodes with Foreman by running the following command on each agent node:<\/p>\n<pre>sudo puppet agent --test --waitforcert 60<\/pre>\n<p>This command will register the agent node with the Foreman server and request a certificate from the Foreman CA.<\/p>\n<p>Puppet binaries are located in the \u201c\/opt\/puppetlabs\/bin\/\u201d directory, which is not in the \u201cPATH\u201d environment variable by default and in the \u201csecure_path\u201d variable that is used for \u201csudo\u201d operations.<\/p>\n<p>Note that the path to the executable files is irrelevant for the Puppet services since the start of the services does not depend on the \u201cPATH\u201d and \u201csecure_path\u201d.<\/p>\n<p>By adding the path to executable files to variables, you can use:<\/p>\n<pre>sudo puppet agent -t<\/pre>\n<p>Instead:<\/p>\n<pre>sudo \/opt\/puppetlabs\/bin\/puppet agent -t<\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56567 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/unnamed-5.png\" alt=\"\" width=\"800\" height=\"511\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/unnamed-5.png 800w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/unnamed-5-300x192.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/unnamed-5-768x491.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/unnamed-5-624x399.png 624w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>With these steps, you must have successfully integrated Foreman with Puppet on Ubuntu 20.04. You can now use the Foreman web interface to manage your Puppet agents and apply configurations to them. Additionally, you can also use Foreman to monitor the state of your servers and troubleshoot any issues that may arise.<\/p>\n<p>&nbsp;<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>&nbsp; Foreman is a powerful open-source tool that helps in managing the infrastructure, including the provisioning, configuration, and monitoring of servers. Puppet is a well-known configuration management tool that can be used in conjunction with Foreman to automate the configuration of servers. This blog post will cover the latest installation and integration of Foreman with [&hellip;]<\/p>\n","protected":false},"author":1542,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":290},"categories":[2348],"tags":[5094],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56525"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1542"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=56525"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56525\/revisions"}],"predecessor-version":[{"id":56571,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56525\/revisions\/56571"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=56525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=56525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=56525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}