MAD-I-T / magento-actions

Github deployment actions for Magento 2
MIT License
99 stars 35 forks source link

Unable to set different 'http_user' #5

Closed deedy-tech closed 3 years ago

deedy-tech commented 3 years ago

Hi I am trying to use the 'deploy-staging' process, to deploy to a Cloudways' hosted server

Cloudways' servers don't use the 'www-data' user for the owner of the web files (they also don't give access to sudo). Therefore the deploy process keeps failing with

`------> Deploying release ... ➤ Executing task deploy:shared ✔ Ok ➤ Executing task deploy:writable ➤ Executing task deploy:failed ✔ Ok ➤ Executing task deploy:unlock ✔ Ok

In Client.php line 96:

The command "cd /mnt/BLOCKSTORAGE/home/XXXXXX.cloudwaysapps.com/xxxxxxxxxx/
tmp//releases/1 && ( chown -RL www-data magento/var magento/pub/static mage
nto/pub/media)" failed.

Exit Code: 1 (General error)
`

I have tried setting the 'http_user: xxxxxxxxxx' in my version of the hosts.yml (and adding override_settings: true) however it has no effect and always tries to set chown with www-data.

Cheers

seyuf commented 3 years ago

Hi @deedy-tech , There is an option to disable sudo (WRITE_USE_SUDO: false). As for the http_user:

http_user
User the web server runs as. If this parameter is not configured, deployer try to detect it from the process list.

So are u sure your issue is related to the www-data?

deedy-tech commented 3 years ago

Hi @seyuf Thanks for the reply.

Thanks for pointing out the WRITE_USE_SUDO, I have already added that to 'env' section (WRITE_USE_SUDO: false)

For Cloudways' servers you basically aren't able to use the chown command to change to different users (they provide an option within their portal for changing file permissions). Which is why I was trying to set the http_user to the user I was connecting as.

In MagentoActions/config/php-deployer/deploy.php, do you not need something like

set('http_user', '{{http_user}}');

at line 13?

I couldn't see where the http_user in the hosts.yml was being used.

seyuf commented 3 years ago

Nope, you was right the first time, host.yml is what you have to edit in order to change the http_user (rpg commente in the file). It's just seems that at the moment the override_settings config option, do no override php-deployer settings only the deployment scripts. Certainly a miss on my part i will fix that ASAP.

seyuf commented 3 years ago

In any case if cloudways do not give access to chown... Im afraid the default setup of this project will fail anyways.

deedy-tech commented 3 years ago

Thanks.

I am going to move it to a AWS EC2 instance, so I have more control.

seyuf commented 3 years ago

Even better, let me know if you face any issues. Regards,

deedy-tech commented 3 years ago

Sorry one other question.

My EC2 instance is IP restricted on port 22, it doesn't seem possible to define the github actions runners ips as they change every week.

Is it possible to define a SSH Jump host in the STAGE_SSH_CONFIG?

Host jump-host User USERNAME Hostname 192.168.1.38

Host destination User USERNAME Hostname 192.168.1.221 Port 22 ProxyCommand ssh -q -W %h:%p jump-host

Cheers

seyuf commented 3 years ago

Never tried, but there should be no issues. You'll just have to replace Host destination by Host staging or Host production that or update your scripts accordingly. One other solution to this issue could be to simply setup a self-hoster runner and whitelist that IP.

seyuf commented 3 years ago

Hi @deedy-tech, not that it matters now, but i had misread your message above demanding the steps to update http_user. Anyways, for those wanting to modify http_user you just have to uncomment it in here the host.yml and override that config/file. Also for those using users with limited permission like on Cloudways servers, i just added a new option that will prevent the deployer to check and/or chown the shared directories rights. You can acheive this by setting deployer: 'no-permission-check' option example here. That's it, i'm closing this.