aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2019-04-22Automating_desktop_setup_with_ansible-pull_part-1.md
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-06-10 22:20:13 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-06-10 22:20:13 +0200
commit0e147a780e74b54afbd56ff7438077d855d5c1c2 (patch)
tree25296b0370513c757416ea6d5e7258b4069b1307 /content/posts/2019-04-22Automating_desktop_setup_with_ansible-pull_part-1.md
parent17d160e5f9cdd4e46b0ab08cf56eaedd8943d885 (diff)
downloadmacroblog.rs-0e147a780e74b54afbd56ff7438077d855d5c1c2.tar.gz
macroblog.rs-0e147a780e74b54afbd56ff7438077d855d5c1c2.tar.bz2
macroblog.rs-0e147a780e74b54afbd56ff7438077d855d5c1c2.zip
ref: Move from HTML to MD
Keep and write in html is pain, so I'm rendering md as html.
Diffstat (limited to 'content/posts/2019-04-22Automating_desktop_setup_with_ansible-pull_part-1.md')
-rw-r--r--content/posts/2019-04-22Automating_desktop_setup_with_ansible-pull_part-1.md97
1 files changed, 97 insertions, 0 deletions
diff --git a/content/posts/2019-04-22Automating_desktop_setup_with_ansible-pull_part-1.md b/content/posts/2019-04-22Automating_desktop_setup_with_ansible-pull_part-1.md
new file mode 100644
index 0000000..58ecb0d
--- /dev/null
+++ b/content/posts/2019-04-22Automating_desktop_setup_with_ansible-pull_part-1.md
@@ -0,0 +1,97 @@
+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).
+
+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
+[Ansible](https://www.ansible.com/). 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 focus on
+[Ansible
+Pull](https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#ansible-pull)
+and
+[Playbooks](https://docs.ansible.com/ansible/latest/user_guide/playbooks.html).
+As better described:
+
+> \[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.
+>
+> [source](https://docs.ansible.com/ansible/latest/cli/ansible-pull.html)
+
+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.
+
+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`:
+
+``` service
+[all]
+localhost
+```
+
+As an experiment we\'re going to write a asks to install vim. Currently,
+ I\'m using [Fedora](https://getfedora.org/) thus we going to use [dnf
+ modeule](https://docs.ansible.com/ansible/latest/modules/dnf_module.html)
+ to install packages, but if you\'re using another distribution look for
+ a equivalent module like [apt
+ module](https://docs.ansible.com/ansible/latest/modules/apt_module.html)
+ for [Ubuntu](https://ubuntu.com/).
+
+ The playbook to install is quite simple:
+
+ ``` yaml
+# main.yaml
+ - hosts: all
+ tasks:
+ - name: install vim
+ dnf:
+name: vim
+state: latest
+```
+
+`hosts:` is required and it has to match our hosts otherwise the
+playbook won\'t run.
+
+`tasks:` is the list of tasks that the playbook will perform, in this
+case will be `dnf install vim`.
+
+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:
+
+
+``` bash
+sudo ansible-playbook --connection=local main.yml
+```
+
+After a few seconds, vim will be installed on your machine.
+
+``` bash
+PLAY [all] *************************************************************
+
+TASK [Gathering Facts] *************************************************
+ok: [localhost]
+
+TASK [install vim] *****************************************************
+ok: [localhost]
+
+PLAY RECAP *************************************************************
+localhost : ok=2 changed=0 unreachable=0 failed=0
+```
+
+This is the first step, next part we shall create a more complex
+playbook and setup repository to run it remotely using `ansible-pull`.