evolution/genesis-wordpress

Scripts don't work with non-debian distros

connorblack opened this issue · 12 comments

Hello!

Came across this tool a couple days ago and I'm loving it, great job!

One issue I'm having is deploying (and provisioning) to non-debian (in my case CentOS) distros. It seems like the scripts are hardcoded to only work with debian.

Is there any way around this?

Howdy! Our stack is primarily Ubuntu, so the Ansible provisioning scripts were built with that in mind.

It's possible to target multiple distros, but would need some guidance on what it takes for this same setup to apply to Red Hat.

(My experience with Red Hat is through Rackspace Hosted, where we had tons of issues of old repos for "security reasons", and we eventually got them to use CentOS. We chose Ubuntu, since a huge portion of the development community seems to favor that for some reason)

Anyway, totally possible, so to kick 'er off, what box do you reference in your Vagrant machine normally? (Or do you not? In which case, which distro+version do you use?)

Sorry, our hosted server is actually running CentOS release 6.4 **

The main problems come with these installations during provisioning from bin/provision:

#!/usr/bin/env bash

## Must be run as root...
if [[ $EUID -ne 0 ]]; then
    echo "This script must be run root:"
    echo "  \$ sudo $0"
    exit 1
fi

# Ansible dependencies
apt-get -qq -y update
apt-get -qq -y install python-software-properties # Ubuntu 12.04
apt-get -qq -y install software-properties-common # Ubuntu 12.10
apt-get -qq -y install python-pycurl

add-apt-repository -y ppa:rquillo/ansible &> /dev/null || exit 1
apt-get -qq -y update

# Ansible
apt-get -qq -y install ansible

# # Run provisioning playbook

(cd "$( dirname "$0" )/../provisioning" && ansible-playbook -i localhost $@ provision.yml)

Though I seem to have gotten the server (mostly) provisioned by substituting this:

#!/usr/bin/env bash

## Must be run as root...
if [[ $EUID -ne 0 ]]; then
    echo "This script must be run root:"
    echo "  \$ sudo $0"
    exit 1
fi

yum -y install ansible.noarch

(cd "$( dirname "$0" )/../provisioning" && ansible-playbook -i localhost $@ provision.yml)

But it eventually fails when (I think) it runs the ansible-playbook script (from terminal):

scp upload complete
  * executing "sudo -p 'sudo password: ' /tmp/*****************.2013-11-26.200619/bin/provision"
    servers: ["staging.*****************.com"]
    [staging.*****************.com] executing command
 ** [out :: staging.*****************.com]
 ** [out :: staging.*****************.com] PLAY [webservers] *************************************************************
 ** [out :: staging.*****************.com]
 ** [out :: staging.*****************.com] GATHERING FACTS ***************************************************************
 ** [out :: staging.*****************.com] ok: [127.0.0.1]
 ** [out :: staging.*****************.com]
 ** [out :: staging.*****************.com] TASK: [Add Node apt-repository] ***********************************************
 ** [out :: staging.*****************.com] failed: [127.0.0.1] => {"failed": true, "item": ""}
 ** [out :: staging.*****************.com] msg: Could not import python modules: apt_pkg. Please install python-apt package.
 ** [out :: staging.*****************.com]
 ** [out :: staging.*****************.com] FATAL: all hosts have already failed -- aborting
 ** [out :: staging.*****************.com]
 ** [out :: staging.*****************.com] PLAY RECAP ********************************************************************
 ** [out :: staging.*****************.com] to retry, use: --limit @/root/provision.retry
 ** [out :: staging.*****************.com]
 ** [out :: staging.*****************.com] 127.0.0.1                  : ok=1    changed=0    unreachable=0    failed=1
 ** [out :: staging.*****************.com]

And I can't for the life of me find a substitute package for python-apt that will run on CentOS.

If I comment out that last line, I can then actually get pretty far when I run cap staging deploy, but again it fails:

executing "sudo -p 'sudo password: ' /etc/init.d/apache2 graceful"
    servers: ["staging.*****************.com"]
    [staging.*****************.com] executing command
 ** [out :: staging.*****************.com] sudo: /etc/init.d/apache2: command not found
    command finished in 233ms
failed: "/bin/bash -c 'sudo -p '\\''sudo password: '\\'' /etc/init.d/apache2 graceful'" on staging.*****************.com

This I've isolated down to main project repo in deployment/lib/server.rb.

sudo "/etc/init.d/apache2 graceful" should be sudo "/etc/init.d/httpd graceful" for non-debian distros.

And that's as far as I got. There are probably some other debian-specific commands scattered in the project that ned to be tracked down.

There's no need to install python-apt if you're already this far. It, along with software-properties-common, is necessary to add the Node apt-repository (the ppa:chris-lea/node.js). So don't worry about those installing, they're only necessary for Node installation.

To bypass that, you just need to install Node the CentOS way, the Node repo has a tutorial on how to do this, you'd just need to update the ansible playbooks to follow those commands rather than using the ubuntu-specific stuff.

Hey AntJanus, so I'm pretty sure I have all the major dependancies installed. Now the problems are with the deployment scripts. If someone is on a non-debian machine, sudo "/etc/init.d/apache2 graceful" needs to be sudo "/etc/init.d/httpd graceful"

The core commands are located here:

https://github.com/genesis/wordpress/blob/master/deployment/lib/server.rb

You can open up your local deploy.rb, copy/paste the offending tasks & make them run the RedHat-specific ones.

Ok, so far so good. One quick question - how do I push to staging.website.com instead of master.staging.website.com?

@connorblack I believe master.staging.website.com and staging.website.com are one in the same. The cool thing is if you create a new branch, check it out, then deploy that branch to staging, it will create an instance of that branch at new-branch.staging.website.com. Note: All staging branches share the same database instance.

Don't I have to do some DNS stuff for every new branch I create? Right now staging.website.com resolves but it only brings me to the main apache test page, but master.staging.website.com doesn't resolve at all.

Also, does anyone know if this package takes care of the virtualhost stuff? Where does it put the Apache config file?

@ericclemmons How nice of you to mention my tutorial. Thanks!

You will need wildcard DNS set for the staging domain!

Hi, sorry to say, but we're currently only supporting Debian currently to keep the ansible stuff light!