Last active
December 19, 2015 05:49
-
-
Save parshap/5906778 to your computer and use it in GitHub Desktop.
Chef recipe refactoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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