Skip to content

Instantly share code, notes, and snippets.

@parshap
Last active December 19, 2015 05:49
Show Gist options
  • Save parshap/5906778 to your computer and use it in GitHub Desktop.
Save parshap/5906778 to your computer and use it in GitHub Desktop.
Chef recipe refactoring
NAME = "parshap"
HOME = "/home/#{NAME}"
# Known hosts
parshap_file "#{HOME}/.ssh/known_hosts" do
source "known_hosts"
mode 0600
end
# Authorized keys
parshap_file "#{HOME}/.ssh/authorized_keys" do
source "authorized_keys"
mode 0600
end
def parshap_file(name, &block)
cookbook_file name do
instance_eval(&owner_config)
instance_eval(&block)
end
end
def parshap_directory(name, &block)
directory name do
instance_eval(&owner_config)
instance_eval(&block)
end
end
def owner_config()
owner NAME
group NAME
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment