{"action":"opened","issue":{"url":"https://api.github.com/repos/servebox/electric_sheep/issues/21","labels_url":"https://api.github.com/repos/servebox/electric_sheep/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/servebox/electric_sheep/issues/21/comments","events_url":"https://api.github.com/repos/servebox/electric_sheep/issues/21/events","html_url":"https://github.com/servebox/electric_sheep/issues/21","id":118878236,"number":21,"title":"Get password database from server configuration","user":{"login":"duckmole","id":542584,"avatar_url":"https://avatars.githubusercontent.com/u/542584?v=3","gravatar_id":"","url":"https://api.github.com/users/duckmole","html_url":"https://github.com/duckmole","followers_url":"https://api.github.com/users/duckmole/followers","following_url":"https://api.github.com/users/duckmole/following{/other_user}","gists_url":"https://api.github.com/users/duckmole/gists{/gist_id}","starred_url":"https://api.github.com/users/duckmole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckmole/subscriptions","organizations_url":"https://api.github.com/users/duckmole/orgs","repos_url":"https://api.github.com/users/duckmole/repos","events_url":"https://api.github.com/users/duckmole/events{/privacy}","received_events_url":"https://api.github.com/users/duckmole/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-25T16:51:21Z","updated_at":"2015-11-25T16:51:21Z","closed_at":null,"body":"From @Pierstoval\r\nFor the config file, last week at the DevOps DDay, I asked Fabrice (@duckmole) whether it was possible to get the password from a config file instead of a ssh key. He answered me \"no\", and one colleague of his (sorry I don't remember the name) said \"But you can script it manually, the Sheepfile is a simple Ruby script\".\r\n\r\nActually, when @duckmole live-coded the example of backing-up two databases, I found the operation very heavy and problematic: if a password changes, the whole process of encrypting the keys has to be restarted.\r\nEven if, yes, it's very secure.\r\n\r\nInstead, I remember using PHP to backup some websites because the config was stored in a PHP file, in variables. So a simple \"include\" would have injected passwords and therefore a change in the passwords would be automatically used by the backup script.\r\n\r\nHere, I think a simple function and regexp could be used for this, like this:\r\nfile_regexp('/path/config/parameters.yml', 'database_user: \"?(.+)\"?$')\r\n\r\nObviously, the regexp has to be built manually, but it's much faster than having to use \"cat file.yml | sed /^regex$/\" for example, because \"sed\" regexp are not \"developer-friendly\" when fast scripting (it's only an opinion though).\r\nThe advantage is that some one-lined examples can be used for the most common apps : config/database.yml for ruby apps, app/config/parameters.yml for symfony apps, wp-config.php for wordpress, etc.\r\nPlus, another advantage is that you can use \"delegators\" to retrieve passwords. For example, if the file is in YAML format, you can specify the parameter path. For symfony apps, for example, you can specify \"yaml_file('app/config/parameters.yml', 'parameters.database_user')\".\r\nThis would parse the file and retrieve the \"database_user\" property under the \"parameters\" root. And this can be done on the whole tree.\r\nSame for anything else like INI or PHP files, you can execute a php process that will echo a var or a constant, for example. Etc., many other ideas.\r\n\r\nIMO this would lead to a more \"DevOps\" system, and add more flexibility to the password gathering.\r\n\r\nSo, does the team agrees on this? :)"}}