diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/posts/2019-03-03-welcome-to-my-blog.org | 15 | ||||
-rw-r--r-- | content/posts/2019-03-07-ansible-part-1.org | 98 | ||||
-rw-r--r-- | content/posts/initial.org | 40 |
3 files changed, 113 insertions, 40 deletions
diff --git a/content/posts/2019-03-03-welcome-to-my-blog.org b/content/posts/2019-03-03-welcome-to-my-blog.org new file mode 100644 index 0000000..42a7405 --- /dev/null +++ b/content/posts/2019-03-03-welcome-to-my-blog.org @@ -0,0 +1,15 @@ +--- +title: "Welcome to my blog" +author: ["Kaushal Modi"] +date: 2019-03-03 +--- + +On this blog, I'll be posting some personal projects that I'm working or some +stuff that I find interesting to talk about, I hope be able to keep it +interesting and produce something of value. + +/Disclaimer/: english it's not my native language so if you find something that +you don't understand I'd love you to open an +[issue](https://gitlab.com/gabrielgio/homestation/-/issuess), or even have +something to add, open a +[MR](https://gitlab.com/gabrielgio/homestation/-/merge_requests) diff --git a/content/posts/2019-03-07-ansible-part-1.org b/content/posts/2019-03-07-ansible-part-1.org new file mode 100644 index 0000000..f1133d6 --- /dev/null +++ b/content/posts/2019-03-07-ansible-part-1.org @@ -0,0 +1,98 @@ +--- +layout: post +title: "Automating setup with ansible-pull part-1" +date: 2019-03-07 +tags: ['ansible', 'ansible-pull', 'linux', 'fedora'] +--- + +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). + +<!--more--> + +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 [[https://www.ansible.com/][Ansible]]. 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 [[https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#ansible-pull][Ansible Pull]] and +[[https://docs.ansible.com/ansible/latest/user_guide/playbooks.html][Playbooks]]. As better described: + +#+BEGIN_QUOTE +[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. + +[[https://docs.ansible.com/ansible/latest/cli/ansible-pull.html][source]] +#+END_QUOTE + +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~: + +#+BEGIN_SRC service +[all] +localhost +#+END_SRC + +As an experiment we're going to write a asks to install vim. Currently, I'm using +[[https://getfedora.org/][Fedora]] thus we going to use [[https://docs.ansible.com/ansible/latest/modules/dnf_module.html][dnf modeule]] to install packages, but if you're using +another distribution look for a equivalent module like [[https://docs.ansible.com/ansible/latest/modules/apt_module.html][apt module]] for [[https://ubuntu.com/][Ubuntu]]. + +The playbook to install is quite simple: + +#+BEGIN_SRC yaml +# main.yaml +- hosts: all + tasks: + - name: install vim + dnf: + name: vim + state: latest +#+END_SRC + +~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: + +#+BEGIN_SRC bash +sudo ansible-playbook --connection=local main.yml +#+END_SRC + + +After a few seconds, vim will be installed on your machine. + +#+BEGIN_SRC +PLAY [all] ************************************************************* + +TASK [Gathering Facts] ************************************************* +ok: [localhost] + +TASK [install vim] ***************************************************** +ok: [localhost] + +PLAY RECAP ************************************************************* +localhost : ok=2 changed=0 unreachable=0 failed=0 +#+END_SRC + + +This is the first step, next part we shall create a more complex playbook and +setup repository to run it remotely using ~ansible-pull~. + diff --git a/content/posts/initial.org b/content/posts/initial.org deleted file mode 100644 index 4326425..0000000 --- a/content/posts/initial.org +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: "Writing Hugo blog in Org (File Export)" -author: ["Kaushal Modi"] -date: 2017-09-10 -lastmod: 2100-12-21T00:00:00+00:00 -tags: ["hugo", "org"] -categories: ["emacs"] -gamma: 10 ---- -* First heading within the post :hugo: -- This post will be exported as - =content/posts/writing-hugo-blog-in-org-file-export.md=. -- Its title will be "Writing Hugo blog in Org". -- It will have /hugo/ and /org/ tags and /emacs/ as category. -- The /lastmod/ property in the front-matter is set automatically to - the time of export. -- The menu item /identifier/ is auto-set. -- The menu item /weight/ and post /weight/ if needed have to be - manually specified as shown above. -** A sub-heading under that heading -- It's draft state will be marked as =true= because of =#+hugo_draft: - true=. - -With the point _anywhere_, do =C-c C-e H h= to export this whole file -titled /Writing Hugo blog in Org/ to a Hugo post. - -The exported Markdown has a little comment footer as set in the /Local -Variables/ section below. -* Demo Source Code - -#+begin_src python -if __name__ == "__main__": - print("Hello World") -#+end_src - - [[file:file]]notes -* COMMENT Local Variables :ARCHIVE: -# Local Variables: -# org-hugo-footer: "\n\n[//]: # \"Exported with love from a post written in Org mode\"\n[//]: # \"- https://github.com/kaushalmodi/ox-hugo\"" -# End: |