Fireship · @fireship

Ansible in 100 Seconds

Uploaded March 28, 2023 · Length 2:34

Ansible in 100 Seconds

Summary

ansible tutorial for automating linux servers with declarative yaml code

  • ansible
  • linux automation
  • declarative code
  • configuration management
  • devops

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    ansible in open source automation tool

  2. 0:02

    that can describe your it infrastructure

  3. 0:04

    with simple declarative code it was

  4. 0:06

    created by Michael DeHaan in 2012 then

  5. 0:09

    acquired by Red Hat a few years later

  6. 0:10

    and today is one of the most popular

  7. 0:12

    configuration management tools most

  8. 0:14

    importantly it uses declarative

  9. 0:16

    push-based yaml code that allows devops

  10. 0:18

    teams to easily automate their Linux

  11. 0:20

    servers increasing efficiency while

  12. 0:22

    reducing the likelihood of human error

  13. 0:24

    it works by making at least one machine

  14. 0:26

    a control node it then connects to

  15. 0:28

    multiple manage nodes and sends them an

  16. 0:30

    ansible module over SSH which can

  17. 0:33

    configure that machine's dependencies

  18. 0:34

    update network settings provision

  19. 0:36

    databases or really any job that you

  20. 0:38

    might need to do more than once

  21. 0:40

    developers write playbooks that contain

  22. 0:42

    a series of jobs called plays each play

  23. 0:44

    is a set of instructions that can be

  24. 0:46

    executed on one or more Target hosts it

  25. 0:48

    will execute each task in order against

  26. 0:50

    all machines in parallel in addition A

  27. 0:52

    playbook is item potent which means it

  28. 0:54

    won't actually make any changes unless

  29. 0:56

    it has to in excellent real world use

  30. 0:58

    case for ansible is to manage your Linux

  31. 1:00

    servers on a platform like lenode we

  32. 1:02

    start by provisioning a server running

  33. 1:04

    Ubuntu as the control node then into it

  34. 1:07

    from the terminal from there we can

  35. 1:08

    install ansible on this machine this

  36. 1:10

    machine needs permission to create and

  37. 1:12

    modify other servers so we'll get an

  38. 1:14

    access token for the lenode API and

  39. 1:16

    store it somewhere securely now what's

  40. 1:18

    awesome about ansible is that it has a

  41. 1:20

    massive ecosystem of pre-built playbooks

  42. 1:22

    that can be accessed on ansible Galaxy

  43. 1:24

    installed a collection for lenode using

  44. 1:26

    the ansible Galaxy command from there

  45. 1:28

    it's a good practice to use ansible volt

  46. 1:30

    to store sensitive information like a

  47. 1:33

    password securely so it's not required

  48. 1:34

    to be directly in a yaml file and will

  49. 1:36

    want to encrypt our personal access

  50. 1:38

    token here and now we're ready to write

  51. 1:40

    our first Playbook create a file in the

  52. 1:41

    develop and directory ending in Dot yml

  53. 1:44

    and then create the first play by giving

  54. 1:46

    it a name like create lenode instance

  55. 1:48

    then the host property is a pattern that

  56. 1:50

    defines one or more machines that will

  57. 1:51

    run this play or they can be listed in a

  58. 1:54

    dedicated inventory file next we can

  59. 1:56

    Define reusable variables or point to

  60. 1:58

    files that contain multiple variables