Contents

Using your cloudbox with two domains

Two domain setup

If you have an existing cloudbox setup and opt for the community version, you might want to split your services between two domains.

Bash aliases

In the Cloudbox Community Wiki there are some useful aliases for your ~/.bash_aliases that simplify working with your cloudbox:

Aliases for the basic cloudbox install:

# cloudbox aliases
cloudbox() {
  cd ~/cloudbox/;
  sudo ansible-playbook cloudbox.yml --tags $1;
  cd -;
}

cloudbox-list() {
  cd ~/cloudbox/;
  sudo ansible-playbook cloudbox.yml --list-tags;
  cd -;
}

cloudbox-update() {
  curl -s https://cloudbox.works/scripts/dep.sh | sudo -H sh; 
  curl -s https://cloudbox.works/scripts/repo.sh | bash;
  cd ~/cloudbox/;
  sudo ansible-playbook cloudbox.yml --tags cloudbox;
  cd -;
}

Community aliases:

# community aliases
community() {
  cd ~/community/;
  sudo ansible-playbook community.yml --tags $1;
  cd -;
}

community-list() {
  cd ~/community/;
  sudo ansible-playbook community.yml --list-tags;
  cd -;
}

community-update() {
  curl -s https://cloudbox.works/scripts/dep.sh | sudo -H sh;
  curl -s https://cloudbox.works/scripts/repo.sh | bash;
  cd ~/cloudbox/;
  sudo ansible-playbook cloudbox.yml --tags community;
  cd -;
}
Tip
If you don’t want the commands to print your directory after executing, you can replace cd -; with cd - > /dev/null;.

Your second domain

New config file

To use your cloudbox with two domains, copy your existing ~/cloudbox/accounts.yml and adapt it:

Run cd ~/cloudbox && cp accounts.yml seconddomain.ymland then edit your new config file:

---
user:
  name: yourusername
  pass: yourpassword
  domain: example.com
  email: [email protected]
cloudflare:
  email: [email protected]
  api: yourapikey

Extending your .bash_aliases

cloudbox-second() {
   cd ~/cloudbox/;
   account=$(cat accounts.yml);
   cp seconddomain.yml accounts.yml;
   cd -;
   cloudbox "$1";
   echo "$account" > ~/cloudbox/accounts.yml;
}
community-second() {
   cd ~/cloudbox/;
   account=$(cat accounts.yml);
   cp seconddomain.yml accounts.yml;
   cd -;
   community "$1";
   echo "$account" > ~/cloudbox/accounts.yml;
}

To apply the changes, run source ~/.bashrc.

Installing ansible roles for your second domain

Now you can either run cloudbox-second role to install a default role for your second domain or community-second role to install a custom role. Note that you won’t be able to run the same role on two domains at once.