Skip to content

Commit

Permalink
Allow to use start-from with provision recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 19, 2024
1 parent 78b3c23 commit e637932
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions recipe/provision.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@

desc('Collects required params');
task('provision:configure', function () {
set('remote_user', get('provision_user'));

$params = [
'sudo_password',
'domain',
Expand Down Expand Up @@ -115,6 +117,8 @@

desc('Adds repositories and update');
task('provision:update', function () {
set('remote_user', get('provision_user'));

// PHP
run('apt-add-repository ppa:ondrej/php -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive']]);

Expand All @@ -130,13 +134,15 @@

desc('Upgrades all packages');
task('provision:upgrade', function () {
set('remote_user', get('provision_user'));
run('apt-get upgrade -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]);
})
->oncePerNode()
->verbose();

desc('Installs packages');
task('provision:install', function () {
set('remote_user', get('provision_user'));
$packages = [
'acl',
'apt-transport-https',
Expand Down Expand Up @@ -171,6 +177,7 @@

desc('Configures the ssh');
task('provision:ssh', function () {
set('remote_user', get('provision_user'));
run("sed -i 's/PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config");
run('ssh-keygen -A');
run('service ssh restart');
Expand All @@ -182,6 +189,7 @@

desc('Setups a firewall');
task('provision:firewall', function () {
set('remote_user', get('provision_user'));
run('ufw allow 22');
run('ufw allow 80');
run('ufw allow 443');
Expand Down
2 changes: 2 additions & 0 deletions recipe/provision/databases.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

desc('Provision databases');
task('provision:databases', function () {
set('remote_user', get('provision_user'));

$dbType = get('db_type');
if ($dbType === 'none') {
return;
Expand Down
2 changes: 2 additions & 0 deletions recipe/provision/php.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

desc('Installs PHP packages');
task('provision:php', function () {
set('remote_user', get('provision_user'));

$version = get('php_version');
info("Installing PHP $version");
$packages = [
Expand Down
2 changes: 2 additions & 0 deletions recipe/provision/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

desc('Setups a deployer user');
task('provision:user', function () {
set('remote_user', get('provision_user'));

if (test('id deployer >/dev/null 2>&1')) {
// TODO: Check what created deployer user configured correctly.
// TODO: Update sudo_password of deployer user.
Expand Down
6 changes: 5 additions & 1 deletion recipe/provision/website.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Deployer;

use function Deployer\Support\escape_shell_argument;

set('domain', function () {
return ask(' Domain: ', get('hostname'));
});
Expand All @@ -14,9 +16,11 @@

desc('Configures a server');
task('provision:server', function () {
set('remote_user', get('provision_user'));
run('usermod -a -G www-data caddy');
run("mkdir -p /var/deployer");
upload(__DIR__ . '/404.html', '/var/deployer/404.html');
$html = file_get_contents(__DIR__ . '/404.html');
run("echo $'$html' > /var/deployer/404.html");
})->oncePerNode();

desc('Provision website');
Expand Down

0 comments on commit e637932

Please sign in to comment.