<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Group3-kb84</title>
    <description>The latest articles on DEV Community by Group3-kb84 (@group3kb84).</description>
    <link>https://dev.to/group3kb84</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F736128%2F6fcebce9-397d-4bf7-9462-27a77a65d771.png</url>
      <title>DEV Community: Group3-kb84</title>
      <link>https://dev.to/group3kb84</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/group3kb84"/>
    <language>en</language>
    <item>
      <title>Additional tips for writing Playbooks</title>
      <dc:creator>Group3-kb84</dc:creator>
      <pubDate>Thu, 28 Oct 2021 14:38:28 +0000</pubDate>
      <link>https://dev.to/group3kb84/additional-tips-for-writing-playbooks-4h84</link>
      <guid>https://dev.to/group3kb84/additional-tips-for-writing-playbooks-4h84</guid>
      <description>&lt;p&gt;Below are a few additional tips for when writing your first few playbooks. These will show you some of the peculiarities of Ansible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Management of software
&lt;/h2&gt;

&lt;p&gt;Installation is dependent upon the platform. For Unix-like systems you can use the package manager of the distribution and for Windows there is no package manager provided. Ansible has the chocolatey module, which is a package manager, that allows you to manage software automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;install chocolatey&lt;/span&gt;
  &lt;span class="na"&gt;win_chocolatey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chocolatey&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chocolatey-core.extension&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Commands
&lt;/h2&gt;

&lt;p&gt;In general the &lt;code&gt;shell&lt;/code&gt; and &lt;code&gt;command&lt;/code&gt; modules, or &lt;code&gt;win_shell&lt;/code&gt; and &lt;code&gt;win_command&lt;/code&gt; for Windows respectively, should not be used as they are not able to use exception and error handling. Even though modules can do a lot, in some cases you must use the &lt;code&gt;shell&lt;/code&gt; or &lt;code&gt;command&lt;/code&gt; modules.  &lt;/p&gt;

&lt;p&gt;There is very little difference between the &lt;code&gt;shell&lt;/code&gt; and &lt;code&gt;command&lt;/code&gt; modules. However the &lt;code&gt;shell&lt;/code&gt; module runs the command in a shell and therefore variables and operations like &lt;code&gt;$HOME&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;, and &lt;code&gt;|&lt;/code&gt; are available. On the other hand, &lt;code&gt;command&lt;/code&gt; is safer as it is not dependent on the host environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm install&lt;/span&gt;
    &lt;span class="s"&gt;command&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm install /&amp;lt;path_to_app_dir&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Running software
&lt;/h3&gt;

&lt;p&gt;There are a couple of options when trying to run a program. One of the options is to run an Ansible shell command. This runs the program in a shell, the same way you would do it from the command line of the device. However many programs have their own modules, which are usually easier to read for humans in the YAML files. If a program needs to keep running after the Ansible configuration, the &lt;code&gt;forever&lt;/code&gt; npm package can be used to prevent the program from stopping after the configuration. Other options do exist to keep software running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;start PiCalc&lt;/span&gt;
    &lt;span class="s"&gt;shell&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s"&gt;forever start ./PiCalc/server.js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ansible</category>
    </item>
    <item>
      <title>Writing Playbooks</title>
      <dc:creator>Group3-kb84</dc:creator>
      <pubDate>Thu, 28 Oct 2021 14:31:50 +0000</pubDate>
      <link>https://dev.to/group3kb84/writing-playbooks-4kdj</link>
      <guid>https://dev.to/group3kb84/writing-playbooks-4kdj</guid>
      <description>&lt;p&gt;&lt;em&gt;Hey here! If you prefer a video over text, we've got you covered!&lt;/em&gt;&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/EsZCQE_E-GY"&gt;
&lt;/iframe&gt;
&lt;br&gt;
In previous posts we talked about host files and the use of modules. Now we will combine these to create and run playbooks.&lt;/p&gt;
&lt;h2&gt;
  
  
  What are playbooks?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bjn19Xfw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rtiknzlqso6jxbby3kau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bjn19Xfw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rtiknzlqso6jxbby3kau.png" alt="Diagram of an Ansible setup" width="520" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this section we will be covering playbooks, which make use of modules in order to automate task execution. &lt;/p&gt;

&lt;p&gt;Playbooks are a list of configurations which, if done correctly, are declarative (meaning, you describe what you want, instead of the steps to get there) and idempotent (you can keep executing the playbooks and you will always get the same result). A playbook can be run in parallel on many hosts at the same time.&lt;/p&gt;

&lt;p&gt;As you can see in the diagram, Ansible accepts a playbook containing modules. Ansible takes this playbook, connects to the hosts you want to configure, and executes the tasks needed to get to the desired configuration.&lt;/p&gt;
&lt;h2&gt;
  
  
  Making a playbook
&lt;/h2&gt;

&lt;p&gt;Playbooks are written in YAML. For this tutorial we will be using &lt;code&gt;nano&lt;/code&gt; to write our first playbook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight postscript"&gt;&lt;code&gt;&lt;span class="nf"&gt;$&lt;/span&gt; &lt;span class="nf"&gt;nano&lt;/span&gt; &lt;span class="nf"&gt;playbook_name.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are a plethora of plugins for all popular IDE’s. These check your syntax without having to execute the playbook to find mistakes. A good example of this is the Ansible plugin for VScode. It is recommended to use these plugins to write playbooks for production.&lt;/p&gt;

&lt;p&gt;We will now write our first playbook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Windows&lt;/span&gt;
  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are the essential elements of a playbook that define the minimal knowledge Ansible will need to configure a machine.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;- hosts:&lt;/code&gt; defines the hosts to which the playbook gets applied. In this case that is the &lt;code&gt;Windows&lt;/code&gt; group&lt;br&gt;
&lt;code&gt;tasks:&lt;/code&gt; a list of tasks that need to be applied to all machines in the group.&lt;/p&gt;

&lt;p&gt;Note that &lt;code&gt;tasks&lt;/code&gt; is still empty, Ansible will apply these tasks from top to bottom to all machines. Let's add a task to install the package manager chocolatey to see how this looks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Windows&lt;/span&gt;
  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;install chocolatey&lt;/span&gt;
    &lt;span class="na"&gt;win_chocolatey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chocolatey&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chocolatey-core.extension&lt;/span&gt;
      &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;- name:&lt;/code&gt; the name of the current step that Ansible will show in the terminal, so you can follow along where you are when you run this playbook.&lt;br&gt;
&lt;code&gt;win_chocolatey:&lt;/code&gt; we've seen before and is the module we'll be using for this task.&lt;br&gt;
&lt;code&gt;name:&lt;/code&gt; and &lt;code&gt;state:&lt;/code&gt; are arguments of this module. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Be aware that arguments are not the same across modules, so you will have to change them depending on the module you will use.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that we have a complete playbook, we can execute it with the &lt;code&gt;ansible-playbook&lt;/code&gt; command followed by the name of the playbook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight postscript"&gt;&lt;code&gt;&lt;span class="nf"&gt;$&lt;/span&gt; &lt;span class="nf"&gt;ansible-playbook&lt;/span&gt; &lt;span class="nf"&gt;playbook_name.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Attributes of modules
&lt;/h1&gt;

&lt;p&gt;When it comes to managing Windows computers, one common module you will use is the &lt;code&gt;win_user&lt;/code&gt; module. It allows you to add users and manage the groups they are in. However to do this you will need to use many of the modules parameters. &lt;br&gt;
Below is a list of all fields that can be assigned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;account_disabled&lt;/code&gt; allows you to disable the user account&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;account_locked&lt;/code&gt; allows you to unlock the user account&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;description&lt;/code&gt; allows you to describe the user&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fullname&lt;/code&gt; provides a way the give the user a name not used for logging in&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;groups&lt;/code&gt; is a field used to define groups that the &lt;code&gt;groups_action&lt;/code&gt; field defines&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;groups_action&lt;/code&gt; allows you to define whether the user should be &lt;code&gt;add&lt;/code&gt;, &lt;code&gt;remove&lt;/code&gt; or &lt;code&gt;replace&lt;/code&gt; assigned groups from the &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;groups&lt;/code&gt; field. It has a default value &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt; this is a required field and defines the vale that is used as login name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;password&lt;/code&gt; allows you to define a plaintext password of a user &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;password_expired&lt;/code&gt; allows you to force the user to change password on their next login&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;password_never_expires&lt;/code&gt; allows you to define if the password expires&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;state&lt;/code&gt; defines if the user account is &lt;code&gt;absent&lt;/code&gt;, &lt;code&gt;present&lt;/code&gt; which will also update the user account, or &lt;code&gt;query&lt;/code&gt; which checks if the settings are applied. as default present is used.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;update_password&lt;/code&gt; is by default set to &lt;code&gt;always&lt;/code&gt; however you can also set it to &lt;code&gt;on_create&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;user_cannot_change_password&lt;/code&gt; allows you to prevent the user from changing their password&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Managing users
&lt;/h2&gt;

&lt;p&gt;Sometimes you want to remove old user accounts or update current user accounts. Below is an example that does exactly this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;remove the user jeff&lt;/span&gt;
  &lt;span class="na"&gt;win_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jeff&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;absent&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;update the user&lt;/span&gt;
  &lt;span class="na"&gt;win_user&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;user&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
    &lt;span class="na"&gt;groups&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;serverabc&lt;/span&gt;
    &lt;span class="na"&gt;groups_action&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;add&lt;/span&gt;
    &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;user is a server and network admin&lt;/span&gt;
    &lt;span class="na"&gt;fullname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;philippa michael&lt;/span&gt;
    &lt;span class="na"&gt;password_expired&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
    &lt;span class="na"&gt;update_password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;on_create&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;default_password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see the user account &lt;code&gt;jeff&lt;/code&gt; was removed in the first task. In the second task however the user account is updated with new settings.&lt;br&gt;
First the user is added to the server group using the &lt;code&gt;groups&lt;/code&gt; and &lt;code&gt;groups_action&lt;/code&gt; fields.&lt;br&gt;
Then the user account is given a description and full name for convenience using the &lt;code&gt;description&lt;/code&gt; and &lt;code&gt;fullname&lt;/code&gt; fields respectively.&lt;br&gt;
Lastly, the password is set to be changed with the &lt;code&gt;password_expired&lt;/code&gt; field and if the user needs to be created it defines a default password with the fields &lt;code&gt;update_password&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up Firefox policies
&lt;/h2&gt;

&lt;p&gt;Some policies need to be added separately as they belong to a specific application. Some of these are having a specific homepage in a Firefox browser, preventing users from installing extensions, and disabling advanced settings. All of these are done by copying a file into the &lt;code&gt;distribution&lt;/code&gt; folder of Firefox. The tasks below install Firefox and then copies a &lt;code&gt;policies.json&lt;/code&gt; file into the correct folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;install firefox&lt;/span&gt;
    &lt;span class="na"&gt;win_chocolatey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;firefox&lt;/span&gt;
      &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;latest&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;provide policies&lt;/span&gt;
    &lt;span class="na"&gt;win_copy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;C:/Program&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Files/Mozilla&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Firefox/distribution"&lt;/span&gt;
      &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;~/policies.json"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;policies.json&lt;/code&gt; file describes the policies that are enabled for Firefox. You can find an description of all possible policies for Firefox &lt;a href="https://github.com/mozilla/policy-templates/blob/master/README.md"&gt;on their Github page&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"policies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"BlockAboutConfig"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ExtensionSettings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"blocked_install_message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Installing extensions is not allowed in this company."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"install_sources"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"about:addons"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"https://addons.mozilla.org/"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"installation_mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"blocked"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"allowed_types"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"extension"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"uBlock0@raymondhill.net"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"installation_mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"force_installed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"install_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Homepage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://bbc.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Locked"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"StartPage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"none"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  In short
&lt;/h2&gt;

&lt;p&gt;In this post we have shown you how to write a basic playbook, how to add tasks to a playbook and explained how the playbook is structured.&lt;/p&gt;

&lt;p&gt;With this we have explained all basic knowledge that you need in order to use Ansible for Windows machines. Thank you for reading! In the next post we will show a few peculiarities that you might encounter when using Ansible. Handy to know, but not required.&lt;/p&gt;

&lt;p&gt;See you there!&lt;/p&gt;

</description>
      <category>ansible</category>
    </item>
    <item>
      <title>All about Ansible modules</title>
      <dc:creator>Group3-kb84</dc:creator>
      <pubDate>Thu, 28 Oct 2021 13:38:49 +0000</pubDate>
      <link>https://dev.to/group3kb84/all-about-ansible-modules-hkp</link>
      <guid>https://dev.to/group3kb84/all-about-ansible-modules-hkp</guid>
      <description>&lt;p&gt;&lt;em&gt;Hey here! If you prefer a video over text, we've got you covered!&lt;/em&gt;&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/0yvsc7lSaVk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AAjV1Sfl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjgcl7dlsvtukkbc35pc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AAjV1Sfl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjgcl7dlsvtukkbc35pc.png" alt="Image description" width="520" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this section we will be zooming in specifically on modules, which are essential for using Ansible to its fullest potential.&lt;/p&gt;

&lt;p&gt;Ansible modules are used to simplify complex tasks. Ansible includes a standard module library with your installation. You are also able to write your own modules if needed. &lt;/p&gt;

&lt;p&gt;Modules are used inside playbooks (which we will cover in the next post) or can be used in the command line. &lt;/p&gt;

&lt;p&gt;Modules are often written using Python and can have the same functionality as any other Python script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using a module from the command line
&lt;/h2&gt;

&lt;p&gt;We have used a module before in the previous post. We used the &lt;code&gt;win_ping&lt;/code&gt; module to test if there is a connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ansible Windows &lt;span class="nt"&gt;-m&lt;/span&gt; win_ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see the &lt;code&gt;-m&lt;/code&gt; signals that the next name is the name of a module. &lt;/p&gt;

&lt;p&gt;Sometimes you want to use a module for a single action, without having to set up a playbook. In this case you may use the command line. Lets say you want to add Google Chrome on 250 Window machines. &lt;/p&gt;

&lt;p&gt;The command would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ansible Windows &lt;span class="nt"&gt;-m&lt;/span&gt; win_chocolatey &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="s2"&gt;"name=googlechrome state=present"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, we are using the &lt;code&gt;win_chocolatey&lt;/code&gt; module to install Google Chrome. The components of the above command are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Windows&lt;/code&gt; -  Name of your host group&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;win_chocolatey&lt;/code&gt; - Name of the module. In this case the windows Chocolatey module &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-a "..."&lt;/code&gt; - Arguments for the module. The &lt;code&gt;present&lt;/code&gt; argument specifies that if the software is not available then to make it available.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each module has its own arguments. You can use the documentation to look up what they are. &lt;/p&gt;

&lt;h2&gt;
  
  
  Available modules
&lt;/h2&gt;

&lt;p&gt;Ansible provides the standard module library which consist of the following module category:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_cloud_modules.html"&gt;Cloud&lt;/a&gt;: tools for managing specific cloud provider actions&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_clustering_modules.html"&gt;Clustering&lt;/a&gt;: contains functionality for managing clusters (such as Kubernetes)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_commands_modules.html"&gt;Commands&lt;/a&gt;: general command and script execution tool set for nodes&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_crypto_modules.html"&gt;Cryptography&lt;/a&gt;: used for general encryption purposes&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_database_modules.html"&gt;Database&lt;/a&gt;: contains modules for managing database servers and database manipulation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_files_modules.html"&gt;Files&lt;/a&gt;: used for reading, writing and altering files&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_identity_modules.html"&gt;Identity&lt;/a&gt;: used for managing user identity services&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_inventory_modules.html"&gt;Inventory&lt;/a&gt;: module for adding hosts to the Ansible playbook and groups&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_messaging_modules.html"&gt;Messaging&lt;/a&gt;: used specifically for Rabbitmq messaging&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_monitoring_modules.html"&gt;Monitoring&lt;/a&gt;: general purpose monitoring for (remote) nodes&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_net_tools_modules.html"&gt;Net Tools&lt;/a&gt;: DNS/IP management and tools for uploading/retrieving files from nodes&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_network_modules.html"&gt;Network&lt;/a&gt;: a vast tool set for all-purpose network management&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_notification_modules.html"&gt;Notification&lt;/a&gt;: used for sending push notification to messaging platforms&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_packaging_modules.html"&gt;Packaging&lt;/a&gt;: modules for the usage of most commonly known package managers &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_remote_management_modules.html"&gt;Remote Management Modules&lt;/a&gt;: used for managing remote hardware resource pools&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_source_control_modules.html"&gt;Source Control Modules&lt;/a&gt;: used for managing source control providers such as Github, Gitlab and Bitbucket&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_storage_modules.html"&gt;Storage Modules&lt;/a&gt;: general storage group management&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_system_modules.html"&gt;System Modules&lt;/a&gt;: management tools for system specific configuration&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_utilities_modules.html"&gt;Utilities modules&lt;/a&gt;: contains utilities specific for Ansible usage&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_web_infrastructure_modules.html"&gt;Web Infrastructure Modules&lt;/a&gt;: used for managing web service related tools&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.ansible.com/ansible/2.9/modules/list_of_windows_modules.html"&gt;Windows&lt;/a&gt;: contains a large tool set of utilities, used specifically for managing Windows hosts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find more information about these categories on &lt;a href="https://docs.ansible.com/ansible/2.9/modules/modules_by_category.html"&gt;the Ansible website&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing custom modules
&lt;/h2&gt;

&lt;p&gt;If you can't find a module that has your desired functionality, you can write your own. If you choose to write your own module, you can use any desired language. For learning more about making your own modules, you can find more at: &lt;a href="https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html"&gt;Developing Ansible modules — Ansible Documentation&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  In short
&lt;/h2&gt;

&lt;p&gt;In this post we have shown how you can execute modules from the command line and we have shown what module categories are available. &lt;/p&gt;

&lt;p&gt;In the next post we will show you how you can combine multiple modules together in playbooks. making it much easier to do large changes in one operation.&lt;/p&gt;

&lt;p&gt;See you there!&lt;/p&gt;

</description>
      <category>ansible</category>
    </item>
    <item>
      <title>Installing Ansible on Ubuntu</title>
      <dc:creator>Group3-kb84</dc:creator>
      <pubDate>Thu, 28 Oct 2021 12:22:33 +0000</pubDate>
      <link>https://dev.to/group3kb84/installing-ansible-on-ubuntu-1klm</link>
      <guid>https://dev.to/group3kb84/installing-ansible-on-ubuntu-1klm</guid>
      <description>&lt;p&gt;&lt;em&gt;Hey here! If you prefer a video over text, we've got you covered!&lt;/em&gt;&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/VQp1ouneK9c"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqww8jbbi2dxszr1omgm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqww8jbbi2dxszr1omgm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During this section, you will be learning how to setup Ansible on a Linux control node and how to setup a proper connection to one (or multiple) host machines by creating a Host inventory. In our example, we will be setting up a connection to Windows hosts, which require a special communication protocol named WinRM.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Ansible on a Linux machine
&lt;/h2&gt;

&lt;p&gt;We will be using Ubuntu LTS 20.04 as an example, which you can download from &lt;a href="https://ubuntu.com/download/desktop" rel="noopener noreferrer"&gt;here&lt;/a&gt; if you want to follow along.&lt;/p&gt;

&lt;p&gt;We are not going to explain how to install Ubuntu on your device (or virtual machine) since we assume that you know how to do that. if you need help with that, then Canonical (The creators of Ubuntu OS) has a nice walkthrough on how to do that &lt;a href="https://ubuntu.com/tutorials/install-ubuntu-desktop" rel="noopener noreferrer"&gt;on their website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you have completed the installation, open the terminal to use &lt;code&gt;apt&lt;/code&gt; (the package manager of Ubuntu) to install Ansible.&lt;/p&gt;

&lt;p&gt;To install the most recent version of Ansible we need to install the Ansible repository into &lt;code&gt;apt&lt;/code&gt;, we can do this with the &lt;code&gt;add-apt-repository&lt;/code&gt; command, which you can find in the &lt;code&gt;software-properties-common&lt;/code&gt; software package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;software-properties-common
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This package might already be installed. If that’s the case, just continue with the rest of the steps.&lt;/p&gt;

&lt;p&gt;Now that we have a way of adding apt repositories, we can add the Ansible repository so that we can install the latest version of Ansible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;add-apt-repository &lt;span class="nt"&gt;--yes&lt;/span&gt; &lt;span class="nt"&gt;--update&lt;/span&gt; ppa:ansible/ansible 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the repository has been added, installing Ansible is as easy as installing it with &lt;code&gt;apt&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;ansible
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After Ansible is done installing we need to install an extension to connect to Windows machines with Ansible. We need to use WinRM connections for this. Why WinRM and not SSH? That’s because as of the time of writing, the SSH module for Windows is in beta, while the WinRM module is not.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;WinRM stands for Windows Remote Management, and is a protocol for managing Windows machines remotely. Similar to SSH.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Support for WinRM connections is not installed into Ansible by default. For that we need a Python package named &lt;code&gt;pywinrm&lt;/code&gt;. Which we need to install with the Python package manager pip.&lt;/p&gt;

&lt;p&gt;First, let’s install &lt;code&gt;pip&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;pip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then install the pywinrm package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"pywinrm &amp;gt;= 0.2.2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything is now installed to be able to connect to Windows machines. &lt;/p&gt;

&lt;h3&gt;
  
  
  Making the Windows client reachable for Ansible
&lt;/h3&gt;

&lt;p&gt;Now that Ansible can use WinRM to connect to Windows machines, we need to configure the Windows machines to allow WinRM connections.&lt;/p&gt;

&lt;p&gt;Before you take these steps, make sure your Powershell is at least version 3.0, and you have at least .net framework 4.0 (as of the time of writing, Windows 10 contains Powershell 5.0 and .net framework 4.8)&lt;/p&gt;

&lt;p&gt;Open Powershell as administrator and use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Net.ServicePointManager&lt;/span&gt;&lt;span class="p"&gt;]::&lt;/span&gt;&lt;span class="n"&gt;SecurityProtocol&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Net.SecurityProtocolType&lt;/span&gt;&lt;span class="p"&gt;]::&lt;/span&gt;&lt;span class="n"&gt;Tls12&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nv"&gt;$url&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$&lt;/span&gt;&lt;span class="nn"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;temp&lt;/span&gt;&lt;span class="s2"&gt;\ConfigureRemotingForAnsible.ps1"&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;New-Object&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-TypeName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;System.Net.WebClient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DownloadFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;powershell.exe&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-ExecutionPolicy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ByPass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-File&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This downloads a Powershell script that enables and configures WinRM for Ansible. Specifically it does the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enables WinRM services &amp;amp; firewall exceptions&lt;/li&gt;
&lt;li&gt;Allow remote login of local users&lt;/li&gt;
&lt;li&gt;Create HTTP &amp;amp; HTTPS listeners for WinRM&lt;/li&gt;
&lt;li&gt;Generate a self-signed certificate for the HTTPS connection &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Warning: This script is going to set up self signed certificates to secure the connection. While this is fine for demo purposes, it’s not enough for production &amp;amp; professional use. If you do want to set up a secure winrm connection for your company. Consider getting a certificate from a Certificate Authority (CA) and setting up WinRM manually.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Making the hosts known to Ansible
&lt;/h3&gt;

&lt;p&gt;Ansible works with a file named “hosts” in &lt;code&gt;/etc/ansible&lt;/code&gt;. In this file you define what the ip’s are of the machines you want to configure automatically with Ansible.&lt;/p&gt;

&lt;p&gt;While this is the easiest way to configure Ansible’s host file. It is not the only way. You can also create ansible.cfg files that point to a host file in a different location. You can read more about this on the documentation on &lt;a href="https://docs.ansible.com/ansible/latest/reference_appendices/config.html" rel="noopener noreferrer"&gt;their website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can group machines together in the host file. You can give these groups names that you can use when specifying which machines need to be configured by Ansible.&lt;/p&gt;

&lt;p&gt;In the file you need to add the following to the end, change everything in capital letters to the values of the host you want to configure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[GROUPNAME]&lt;/span&gt;
&lt;span class="c"&gt;# ip's of machines here
&lt;/span&gt;&lt;span class="nn"&gt;[GROUPNAME:vars]&lt;/span&gt;
&lt;span class="py"&gt;ansible_user&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;WINDOWS_USER&lt;/span&gt;
&lt;span class="py"&gt;ansible_password&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;WINDOWS_PASSWORD&lt;/span&gt;
&lt;span class="py"&gt;ansible_connection&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;winrm&lt;/span&gt;
&lt;span class="c"&gt;# more variables can be put in here.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;[GROUPNAME:vars]&lt;/code&gt; you specify the details of the machines you want to configure. &lt;br&gt;
In this case we specify the user, the user password and the connection type when we want to connect to any of these machines in this group.&lt;/p&gt;

&lt;p&gt;For our example we will be using the following settings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Windows]&lt;/span&gt;
&lt;span class="err"&gt;192.168.178.201&lt;/span&gt;
&lt;span class="nn"&gt;[Windows:vars]&lt;/span&gt;
&lt;span class="py"&gt;ansible_user&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;Administrator&lt;/span&gt;
&lt;span class="py"&gt;ansible_password&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;root&lt;/span&gt;
&lt;span class="py"&gt;ansible_connection&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;winrm&lt;/span&gt;
&lt;span class="py"&gt;ansible_winrm_server_cert_validation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ignore&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;You might have noticed that we have disabled server certificate validation in our example above. Since we are using a self-signed certificate, we have disabled the certificate validation. If you do want to set up a connection with certificate validation, you will need to buy a certificate from a Certificate Authority. And set up WinRM to use this certificate.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing if Ansible can reach your hosts
&lt;/h3&gt;

&lt;p&gt;Once you have configured your host file you can test if Ansible can reach your machines with the &lt;code&gt;win_ping&lt;/code&gt; module.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ansible Windows &lt;span class="nt"&gt;-m&lt;/span&gt; win_ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can edit the &lt;code&gt;Windows&lt;/code&gt; argument to the Windows group name you have written in your host file. You can also use &lt;code&gt;all&lt;/code&gt; to target all groups. &lt;/p&gt;

&lt;h2&gt;
  
  
  In short
&lt;/h2&gt;

&lt;p&gt;In this post we have shown you how to install Ansible on a Ubuntu machine and how to configure Ansible &amp;amp; Windows so that Ansible can reach your Windows machine. In the next post we will be explaining What modules are, which kinds are available and how you can use them from the command line.&lt;/p&gt;

&lt;p&gt;See you there!&lt;/p&gt;

</description>
      <category>ansible</category>
    </item>
    <item>
      <title>Introduction to Ansible</title>
      <dc:creator>Group3-kb84</dc:creator>
      <pubDate>Thu, 28 Oct 2021 12:16:13 +0000</pubDate>
      <link>https://dev.to/group3kb84/introduction-to-ansible-2e0o</link>
      <guid>https://dev.to/group3kb84/introduction-to-ansible-2e0o</guid>
      <description>&lt;p&gt;&lt;em&gt;Hey here! If you prefer a video over text, we've got you covered!&lt;/em&gt;&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Vwl2uiysruQ"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Ever wondered how cloud providers create virtual machines that "just work" so easily? The secret is that they use tools to quickly spin up and configure virtual machines for you, using tools that automate configuring these machines.&lt;/p&gt;

&lt;p&gt;We will be talking about one of these configuration tools in this post, Ansible.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Ansible?
&lt;/h2&gt;

&lt;p&gt;Ansible is a tool that is able to automate repetitive tasks and configure multiple machines at the same time. Ansible works with Python and is executable via the command line.&lt;/p&gt;

&lt;p&gt;Ansible is meant to replace the custom scripts that server admin's previously wrote by themselves. Usually these scripts were used once and needed to be rewritten and redistributed every time something needed to change to the environment.&lt;/p&gt;

&lt;p&gt;Ansible solves this problem, by giving you a way to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;describe how you want to configure machines&lt;/li&gt;
&lt;li&gt;deploy these configuration changes on demand&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, you can automate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installing new software&lt;/li&gt;
&lt;li&gt;adjusting passwords&lt;/li&gt;
&lt;li&gt;updating system OS&lt;/li&gt;
&lt;li&gt;adjusting security policies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1iPeyVcM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydhxlqrmsk8q1q36xqad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1iPeyVcM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydhxlqrmsk8q1q36xqad.png" alt="Diagram describing the architecture of Ansible" width="519" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above gives you a general overview of the architecture of Ansible. You can see that there is a Ubuntu server with Ansible installed. Ansible reads the playbook you created, and uses the hosts file and required modules to connect to the Windows hosts you want to configure.&lt;/p&gt;

&lt;p&gt;We will talk in greater detail about each of these parts of Ansible in future posts. Just keep in mind for now that Ansible connects to machines to configure them the way you describe in the playbook.&lt;/p&gt;

&lt;p&gt;You might also have noticed that we are only connecting to Windows machines. This is part of the example that we are going to use for this tutorial, which we will introduce now.&lt;/p&gt;

&lt;h2&gt;
  
  
  The final goal
&lt;/h2&gt;

&lt;p&gt;We think that the best way to learn how to work with Ansible is by working towards a goal. Therefore we have thought of a scenario that we will use as a goal for this series:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;An organization has recently created a new department. The company has bought a bunch of new machines for the employees that are going to work in the new building for the department. We are responsible for configuring the windows machines so that they match the company policies.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;only administrators are allowed to install software on the machines.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;every machine must have Firefox installed&lt;/em&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;installing extensions must be disabled.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;disable advanced settings on Firefox (about:config page)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;default homepage of the browser is &lt;a href="https://bbc.com"&gt;https://bbc.com&lt;/a&gt; so that employees can track news about our company.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why this example? There is a lack of tutorials that explain both installing &amp;amp; configuring and how to then use Ansible. These tend to be separate tutorials. We also specifically target windows machines for this tutorial, since Windows machines are the norm in most companies.&lt;/p&gt;

&lt;p&gt;You are free to use a different scenario for yourself of course, but you will need to adjust parts of these tutorials to your situation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next up
&lt;/h2&gt;

&lt;p&gt;In the next few posts we will be covering the following subjects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installing Ansible on a Ubuntu machine.&lt;/li&gt;
&lt;li&gt;Modules, what they are, and which ones are available&lt;/li&gt;
&lt;li&gt;combining modules with playbooks, to automate configuring machines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See you there!&lt;/p&gt;

</description>
      <category>ansible</category>
    </item>
  </channel>
</rss>
