aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2019-03-07Automating_desktop_setup_with_ansible-pull_part-1.html
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-05-15 15:34:36 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-05-15 15:34:36 +0200
commit231f2cb2205988cf87062bc9f595307af1ed827f (patch)
treef1094bf50677abed5266feb17c65240a45d7a387 /content/posts/2019-03-07Automating_desktop_setup_with_ansible-pull_part-1.html
parent46e6b5fa84b1ec6e08f124c478909ec745562214 (diff)
downloadmacroblog.rs-231f2cb2205988cf87062bc9f595307af1ed827f.tar.gz
macroblog.rs-231f2cb2205988cf87062bc9f595307af1ed827f.tar.bz2
macroblog.rs-231f2cb2205988cf87062bc9f595307af1ed827f.zip
feat: Add missing blog post
Add the missing blog post from my hugo blog. Also add a locustfile so I can do some stress test locally.
Diffstat (limited to 'content/posts/2019-03-07Automating_desktop_setup_with_ansible-pull_part-1.html')
-rw-r--r--content/posts/2019-03-07Automating_desktop_setup_with_ansible-pull_part-1.html94
1 files changed, 94 insertions, 0 deletions
diff --git a/content/posts/2019-03-07Automating_desktop_setup_with_ansible-pull_part-1.html b/content/posts/2019-03-07Automating_desktop_setup_with_ansible-pull_part-1.html
new file mode 100644
index 0000000..d06a648
--- /dev/null
+++ b/content/posts/2019-03-07Automating_desktop_setup_with_ansible-pull_part-1.html
@@ -0,0 +1,94 @@
+<section>
+ <p>
+ Every time that I do a clean install on my machine it takes a few hours till I
+ get to point where I was before formatting it, install all packages, select
+ themes, icons, fonts, install IDEs, extensions and so on. After doing it a few
+ times I came to the conclusion that I would save time by spending time
+ automating this chore, and as a result, I could tinker a little more with my
+ system and not worry about spending a weekend re-installing everything (which
+ have happened more time that I'd like to remember).
+ </p>
+ <p>
+ So after a few attempts using python and bash I ended with many files and
+ keep everything organized and concise turned out to be more tedious than the
+ setup itself. So there comes <a href="https://www.ansible.com/">Ansible</a>.
+ It is an enterprise-graded software used to automate tasks. It has A LOT OF
+ features and it can be really helpful if you're a sysadmin but for now we're
+ going to focuson
+ <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#ansible-pull">
+ Ansible Pull
+ </a>
+ and
+ <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks.html">
+ Playbooks
+ </a>. As better described:
+ <blockquote>
+ [Ansible-Pull] is used to up a remote copy of ansible on each managed
+ node, each set to run via cron and update playbook source via a source
+ repository. This inverts the default push architecture of Ansible into a
+ pull architecture, which has near-limitless scaling potential.
+
+ Playbooks are Ansible’s configuration, deployment, and orchestration
+ language. They can describe a policy you want your remote systems to
+ enforce, or a set of steps in a general IT process.
+ (<a href="https://docs.ansible.com/ansible/latest/cli/ansible-pull.html">source</a>)
+ </blockquote>
+ </p>
+ <p>
+ The goal is to pull and run a playbook remotely using a git repository. The
+ playbook will describe the tasks needed to setup our machine from scratch.
+ <br/>
+ But first lets tinker a bit a with playbooks locally with ansible-playbook,
+ to do so we need to add localhost to ansible's hosts list. Add it to
+ /etc/ansible/hosts:
+<pre><code>[all]
+localhost</code></pre>
+ </p>
+ <p>
+ As an experiment we're going to write a asks to install vim. Currently, I'm
+ using Fedora thus we going to use dnf modeule to install packages, but if
+ you're using another distribution look for a equivalent module like apt
+ module for Ubuntu.
+
+ The playbook to install is quite simple:
+
+<pre><code># main.yaml
+- hosts: all
+ tasks:
+ - name: install vim
+ dnf:
+ name: vim
+ state: latest</code></pre>
+ <dl>
+ <dt>host</dt>
+ <dd>it is required and it has to match our hosts otherwise the playbook won't run.</dd>
+ <dt>taks</dt>
+ <dd>
+ it is the list of tasks that the playbook will perform, in this case
+ will be dnf install vim.
+ </dd>
+ </dl>
+ </p>
+ <p>
+ To run a playbook use the command ansible-playbook commando to run main.yml
+ direct from disk, do to so just run the following command:
+<pre><code>sudo ansible-playbook --connection=local main.yml</code></pre>
+ </p>
+ <p>
+ After a few seconds, vim will be installed on your machine.
+<pre><code>PLAY [all] *************************************************************
+
+TASK [Gathering Facts] *************************************************
+ok: [localhost]
+
+TASK [install vim] *****************************************************
+ok: [localhost]
+
+PLAY RECAP *************************************************************
+localhost : ok=2 changed=0 unreachable=0 failed=0</code></pre>
+ </p>
+ <p>
+ This is the first step, next part we shall create a more complex playbook and
+ setup repository to run it remotely using ansible-pull.
+ </p>
+</section>