dev-master
9999999-dev https://github.com/slava-vishnyakov/gerar-phpPHP Configuration Management
MIT
configuration
Wallogit.com
2017 © Pedro Peláez
PHP Configuration Management
... because I'm too lazy to remember Puppet or Chef syntax., (*1)
This is an experiment in configuration management. Open example.php if you will., (*2)
Currently only Ubuntu is implemented. Probably going to implement CentOS later., (*3)
All commands must be run as root, (*4)
apt-get update && apt-get install -y php5-cli && (wget -qO - http://git.io/FhkM4A | php)
run same command to update Gerar, (*5)
gerar --set-hostname your-host-name.com gerar some-file.php
passenger-add-host commandRead the source at http://git.io/oVoLFg, (*6)
wget -qO - http://git.io/oVoLFg | gerar passenger-add-ruby-host test.com
You should now have directory to run your Passenger/Nginx Rails application., (*7)
<?php namespace Gerar;
Hostname::change('vagrant.local');
Hostname::run('vagrant.local', function() {
Console::log('Hello!');
});
Hostname::run('vagrant.local', function() {
Ubuntu::fixLocales();
Ubuntu::update();
});
Package::named('php5-cli mysql-server git imagemagick')
->shouldBeInstalled();
Service::named('apache2')
->shouldBeInstalled()
->shouldBeRunning()
->shouldBeRunningAtReboots();
DoOnce::run('initializeServer', function() {
Console::log('We have an ignition!');
});
File::named('/var/www/index.html')->write('Bender is great!');
Http::request('http://localhost/')
->onSuccess(function($request, $response) {
Console::log('My new code is "' . $response->getBody() . '"');
})
->run();
Port::number(810)
->ifNotResponding(function() {
Console::log('Oops, port 810 is not responding, maybe we should start apache? Hint: won\'t help');
Service::named('apache2')->start();
});
File::named('test.txt')->write(microtime(true));
File::named('test.txt')
->whenChanges(function() {
Console::log('Hello, World appears!');
})
->write('Hello, world!')
->replaceIfPresent('world', 'Gerar')
->replaceIfPresent(new Regexp('/He..o/'), 'Howdy');
User::named('root')
->shouldHaveSshKey()
->mailPublicKeyOnce('user@super-server.com');
User::named('alex')
->shouldBePresent()
->haveSshKeyFrom('files/alex.ssh')
->shouldBeInGroup('sudo')
->shouldHaveNoPasswordSudoFor('/usr/sbin/service')
->shouldHaveSudoFor('/bin/vi');
Console::log('My external IP is ' . ThisServer::mainExternalIp());
EtcHosts::file()
->shouldResolve('rarestblog.com', '127.0.0.1')
->shouldNotResolve('rarestblog.com');
Ssh::server()->securify();
What it does:, (*8)
User::shouldHaveOneSudoUserWithSshKey();
Ssh::server()
->shouldNotAllowRoot();
->shouldNotAllowPlainTextPasswords();
Git::src('git@github:')
->shouldBeAt('/home/git')
->shouldBeOnBranch('origin/production');
Cron::named('artisan-cleanup')
->ofUser('root')->shouldRun()->daily()->run('php artisan cleanup');
Nginx::server()
->shouldBeInstalled()
->shouldProxy('http://rarestblog.com/update-328719', 'http://localhost:8000/')
->shouldProxy('http://rarestblog.com/', 'http://localhost:9000/')
->shouldServePhpFpm('rarestblog.com', '/home/user/php/myApp/public')
->shouldServePhpFpm('rarestblog.com', '/home/user/php/myApp/public/index.php');
NginxPassenger::server()
->shouldBeInstalled()
->shouldServeRailsApp('/home/user/rails/my_app/public');
Apache::server()
->shouldServePhp('rarestblog.com', '/home/user/php/myApp/public');
WebApp('127.0.0.1', 8000)
->url('/update-182739')->shouldRun('cd /home/user && php update.php');
SshHost('backup')
->shouldBeAccessibleForUser('user');
$password = RandomPassword::named('rarestblog-db-password');
MySQL::server()
->shouldHaveDatabase('rarestblog')
->shouldHaveUser('rarestblog', '127.0.0.1', $password)
->userShouldHaveFullAccessTo('rarestblog', '127.0.0.1', 'rarestblog.*');
File::named('/var/www/database.php')
->fromTemplate('files/database.php', array('password', $password));
Firewall::rules()
->shouldAllowToPort(22, '234.234.234.234')
->shouldNotAllowAnyoneElseToPort(22);
Gerar()->shouldUpdateItselfEvery(15, 'minutes');
PHP Configuration Management
MIT
configuration