Monday, August 21, 2017

How to setup the knife spork config?

Steps to setup  knife spork configuration:

Step1: We have to config directory in the chef-repo  directory in the local machine.

i.e 

 { /users/tom/chef/chef-repo }  —>   ls -la 
 .chef
 .git
 .gitignore
.rubocop.yml
 LICENSE
 README.md
 chefignore
 config
 cookbooks
environments
 roles

Go to   >> config directory

cd  config    >>      go to   vi spork-config.yml
 .
 ..
 code_generator
 rubocop.yml
spork-config.yml
spork-config.yml-template


vi spork-config.yml

default_environments:
  -  development      (these are the  environments)
environment_xxxxxxxxx:
  production_xxxxxxxxx:
     -   production-west bengal
     -   production-mumbai
     -   production-delhi
  stg_group:
    - staging-west bengal
    - staging-mumbai
    - staging-delhi
version_change_threshold: 2
preserve_constraint_operators: true
environment_path: "/users/tom/chef/chef-repo/environments"      (local path that is related to the  chef  environment directory)
save_environment_locally_on_create: true
role_path: "/users/tom/chef/chef-repo/roles"
custom_plugin_path: " /users/tom/chef/chef-repo/spork-plugins"
always_promote_remote: true
skip_berkshelf: false
role_match_file_name: true
json_options:
  indent: "    "
plugins:
  foodcritic:
    tags: ['~FC014']
  git:
    enabled: true
    auto_push: true
    branch: master
  rubocop:
    epic_fail: false
    show_name: false
    autocorrect: false
    out_file: <file>
    sev_level: <C|W|E>
    lint: false

——————————————————————————————————————————————————
Note:

when we use this commands:

1)Knife spork commands
2)knife promote commands

  1. knife spork commands

knife spork omni   cookbook name  (when we use the omni, you no need to mention about the specific environment, it goes to the default environment).

  2.  knife promote commands

once the cookbook finished testing, you need to promote the cookbook to the different environments.(for example:Dev,staging  and production)
when we use the certain specific environment,to promote (update the cookbook),we use the knife promote commands.
——————————————————————————————————————————————————
Note:

We have to install this gem,inorder to make knife spork commands  to work

chef gem install knife-spork
——————————————————————————————————————————————————
Standard template:

cat  spork-config.yml-template


default_environments:
  - devlop environment
environment_groups:
  production_group:
    - production-westbengal
    - production-kolkatta
    - production-Mumbai
  stg_group:
    - staging-westbengal
    - staging-kolkatta
    - staging-Mumbai
version_change_threshold: 2
preserve_constraint_operators: true
environment_path: "/your/chef/environment/path/chef-repo/environments"
save_environment_locally_on_create: true
role_path: "/your/chef/environment/path/chef-repo/roles"
custom_plugin_path: "/your/chef/environment/path/chef-repo/spork-plugins"
always_promote_remote: true
skip_berkshelf: false
role_match_file_name: true
json_options:
  indent: "    "
plugins:
  foodcritic:
    tags: ['~FC014']
  git:
    enabled: true
    auto_push: true
    branch: master
  rubocop:
    epic_fail: false
    show_name: false
    autocorrect: false
    out_file: <file>
    sev_level: <C|W|E>

    lint: false

No comments:

Post a Comment