Thursday, 5 April 2018

Basic Ansible in 10 mins


  • "site.yml" file
    • playbook containing
      • "roles" that will be applied to individual host groups / "hosts"
      • how the hosts will be accessed
        • and by what user to run as
      • Puppet equivalent is "nodes.pp"
  • "hosts" file
    • use real/local DNS hostname to define which hosts are in which hostgroups
      • example: webserver1, webserver2, haproxy1, haproxy2, mongo1, mongo2
      • some variables like "port" can be added too
  • "group-vars" directory
    • key/value pairs to use when generating output from template files
    • files named identically to hostgroup names defined in "hosts" file
    • these are more in-line in Puppet, and less controllable/flexible
  • "roles" directory
    • Puppet equivalents are "modules"/"classes"
    • directories arbitrarily named to match "roles" in site.yml
    • e.g. "tomcat", "common", "mongod"
    • "templates" directory
      • files with variables that are resolved using "group-vars" key/values
      • moved on to target systems using task keyword "template"
      • same name is used in Puppet
    • "files"
      • raw files to be moved into place on the target filesystems
      • used by tasks with keyword "file"
      • same name used in Puppet
    • "handlers"
      • "main.yml"
      • control system services on target systems
        • "service" keyword
        • "state", e.g. "restarted"
        • in Puppet, these are not broken out from other "resources"
    • "tasks"
      • this is the core list of actions to perform on target systems
      • Puppet equivalents are "includes"/"classes", maybe "modules" as well
      • "main.yml"
        • collection of tasks
        • uses yml structure
          • "name" is arbitrary reference for developers
          • ansible keyword to perform some action on the system
            • ansible keywords: "file", "template", "command"
              • puppet equivalents are called "resources"
          • conditionals/dependencies: "when", "notify", "wait_for"


No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Interview questions: 2020-12

Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer  Networking Layer 1 vs Layer 4 haproxy u...