Sunday, 11 March 2018

AWS OpsWorks Stacks (Chef)


Chef Client
  • Runs in local mode
  • Relies on Chef-zero
    • lightweight local Chef server that uses local repository
    • allows to use chef search and data bags
  • Platforms
    • Linux: Chef 12 (and earlier)
    • Windows: Chef 12.2
  • Requires Ruby
    • Linux - installed by default
    • Windows - executable comes with Chef 12.2


Cookbook
  • Associated with OpsWorks Stack
  • Gets copied to the instance by OpsWorks
  • Can be manually updated afterwards
    • Command -> Update Custom Cookbooks
  •  Structure
    • attributes
    • recipes
    • templates
    • other
    • metada.rb
      • name
      • description
      • version
      • depends
        • other cookbook
      • ...

Cookbook Repository
  • Linux: Git, Subversion
  • Windows: Git
  • S3 Archive
  • Stack can have only one repository
    • It may contain multiple cookbooks
    • Use Berkshelf to workaround the limitation

Recipe
  • Ruby code (.rb)
  • Declaratively describes part of environment
    • similar to CF::Template
  • Domain Specific Language (DSL)
    • e.g. package translated to appropriate package manager
  • Associated with a layer
  • Types
    • OpsWorks recipies
    • Custom recipies 
      • empty run_list by default
    • OpsWorks and Custom are run in 2 isolated environments 
      • no conflicts between the two
  • Can be run manually
    • Command -> Execute Recipes

Attributes
  • Key value pairs
  • Used by Chef 11.10 and earlier versions
    • In Chef 12 depracted by Data Bags

Data Bag
  • Collection of attributes (custom JSON)
  • Chef concept
    • Normally uploaded to Chef server but here there is no Chef Server in OpsWorks Stacks
  • Available on Chef 12
  • Supersede "Attributes"
  • Defined on Stack, Layer or Deployment level
  • Example
    • search("aws_opsworks_layer").first
Run-List
  • Ordered list of roles and recicpes to be run
  • Empty run-list used for diagnostic purposes
    • exclude Chef issue 

Berkshelf
  • Dependency manager for Chef
  • Used to workaround "single cookbook repository" for a stack
    • Enable Berkshelf for the stack
    • Add Berksfile
      • Lists dependencies



No comments:

Post a Comment