LibOps CLI
The LibOps CLI is a useful utility to interact with your LibOps site.
Install
Prerequiste (gcloud)
The LibOps CLI requires Google Cloud's gcloud
CLI to be installed and authenticated on the same machine you run LibOps CLI commands from.
So before installing LibOps you must:
After gcloud
is installed you can install LibOps CLI using homebrew or a binary.
Homebrew
You can install the LibOps CLI using homebrew
brew tap libops/cli
brew install libops
Download Binary
Instead of homebrew, you can download a binary for your system from the latest release
Then put the binary in a directory that is in your $PATH
Usage
After installing the CLI, you can see the list of commands by running libops --help
. The LibOps CLI should be ran from the root of your GitHub repository. This is so the CLI can automatically read the name of your site without having to pass the --site
flag to specify the name.
$ libops --help
Interact with your libops site
Usage:
libops [command]
Available Commands:
backup Backup your libops environment
completion Generate the autocompletion script for the specified shell
config-ssh Populate ~/.ssh/config with LibOps development environment
drush Run drush commands on your libops environment
get Display information about your LibOps environment.
help Help about any command
import Import resources to your LibOps environment.
sequelace Connect to your LibOps database using Sequel Ace (Mac OS only)
set Set information on your LibOps environment.
sync-db Transfer the database from one environment to another
Flags:
-e, --environment string LibOps environment (default "development")
-h, --help help for libops
-p, --site string LibOps project/site (default "YOUR-LIBOPS-SITE")
-v, --version version for libops
Use "libops [command] --help" for more information about a command.
Default environment
Any command you run with libops
will run against your development environment. This can be changed by passing the -e
or --environment
flag. e.g.
libops backup -e production
Commands
set developer
Use this command to add a developer to your LibOps site environments.
LibOps site environments and CLI commands are protected by a firewall and/or gcloud authentication. To provide access to a developer sara@institution.edu
who works from two locations with IP addresses 1.2.3.4
and 5.6.7.8
you could run the command:
libops set developer \
--google-account sara@institution.edu \
--skip-pub-key \
--ip 1.2.3.4/32 \
--ip 5.6.7.8/32
git add libops.yml
git commit -m "Adding Sara"
git push origin development
If you happen to have her public SSH key on your computer, you could also set her up for SFTP access.
libops set developer \
--google-account sara@institution.edu \
--pub-key /path/to/sara/id_rsa.pub
Similarly, you could also set yourself up by running
libops set developer
That command will automatically read your gcloud authenticated email, SSH public key, and public IP address and add the information to libops.yml
.
drush
You can use libops drush
to execute drush commands against your LibOps environment.
Reset super user password
libops -e production drush -- uli --uid 1
Clear the cache
You could clear the cache on your development environment by running
libops drush -- cr
sequelace
On Mac OS with Sequel Ace installed, running libops sequelace
will open a connection to your LibOps development environment database. You could connect to production similarly via
libops sequelace -e production
get config
Running libops get config
will run drush cex
on your environment, download the contents of the config export, and save that export to your local checked out git repo. You could export your config from production and push the config with something like:
cd /path/to/your/libops/site
libops get config -e production
git add --all config
git commit -m "drush cex"
git push origin development
get info
Running libops get info
will return a JSON string containing connection information for different aspects of your LibOps environment:
libops get info | jq .
{
"database": {
"host": "mariadb",
"name": "drupal",
"port": 3306,
"credentials": {
"username": "root",
"password": "***"
}
},
"drupal": {
"url": "https://site.domain"
},
"matomo": {
"url": "https://site.domain/matomo/",
"credentials": {
"username": "***",
"password": "***"
}
},
"ssh": {
"host": "10.1.2.255",
"port": 1234,
"credentials": {
"username": "****"
}
}
}
backup
Running libops backup
will backup the database for your LibOps environment. For example you could backup the production database by running:
libops backup -e production
import db
Running libops import db
can get a SQL file on your local machine imported into a LibOps environment. For example, to import a SQL file called "drupal.sql" from your local machine to development you can run:
libops import db --file drupal.sql
sync-db
Running libops sync-db
can copy the database from one environment into another. For example, to import the production database into development you can run:
libops sync-db --source production --target development