Download the PHP package linkorb/infra without Composer

On this page you can find all versions of the php package linkorb/infra. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package infra

Introduction

Infra allows you to define all objects in your infrastructure in a way that you can load it into a GraphQL service. For example: Hosts, HostGroups, Users, Dns, Monitoring, BackupRules, Deployments, etc, and all of their relationships.

Accessing your infrastructure as a graph allows you to do a couple of cool things:

Resources

You define your infrastructure as a set of Resources in YAML files. The format is heavily inspired by Kubernetes. Here's an example:

For a more comprehensive example, see the example/ directory in this repository.

You can define your resources in standalone YAML files, or (as in this example) configure multiple resources in one file using YAML's multiple document feature

If you're familiar with Kubernetes, you'll feel right at home.

Each resource specifies it's type using the kind key. A list of available resource types is provided below.

Resources contain a metadata key that allows you to specify the resource name, description, a set of labels and annotations (more on metadata below).

The spec key configures the resource, and it's available keys depend on the kind of resource you're creating.

Installation

cd /opt
git clone [email protected]:linkorb/infra.git
cd infra
composer install # See https://getcomposer.org/download/ if you don't have composer installed yet

NOTE: It is strongly recommended to add bin/ to your environment's PATH variable, so you can easily invoke the infra command-line tool from anywhere on your system.

If you're using Bash, you can do this by adding the following line to your ~/.bashrc file:

PATH=/opt/infra/bin:$PATH

Don't forget to open a new bash session for the changes to take effect (close your terminal, or just run bash again).

Configuration

Infra decides where to load it's infrastructure data based on the INFRA_CONFIG environment variable. It should contain a path to directory that contains a set of YAML files describing your infrastructure.

You can define the variable wherever you like. For example in your ~/.bashrc, or a .env file in the root of the infra directory (i.e. /opt/infra/.env). A .env.dist file is provided.

If INFRA_CONFIG is undefined, it will point to the example/ directory as a default.

Example project

The example/ directory contains an example infrastructure configuration (You can view example/README.md for it's details). To load it, make sure your INFRA_CONFIG variable points to the example/ directory (absolute path required), or simply leave INFRA_CONFIG undefined: the example project is loaded by default.

It is recommended to explore the example project first, before using infra to configure your own infrastructure. The example configuration will contain examples for all relevant resource types, configured in a sensible way to show you all available functionality.

Once you're ready to define your own infrastructure, simply point INFRA_CONFIG to a new directory (ideally a git repository), and start creating configuration files there.

Usage

You can get a list of available commands by simply typing infra list or just infra.

Exploring using the get command.

The infra get command lets you explore your infrastructure configuration. Type infra get --help for it's options. All arguments are optional, and the more you specify, the more specific your response will be. Some examples:

Running GraphQL queries

The infra query command let's you perform a GraphQL query against your infrastructure configuration. It reads the query from stdin and outputs the response (as json) to stdout.

For example:

infra query < /opt/infra/example/graphql/example.graphql

Introspection is also enabled, so you can execute the following command to get a full export of all supported types with detailed information about available fields:

infra query < /opt/infra/example/graphql/introspection.graphql

Listing hosts (host expansion algorithm)

The infra host:list <hosts> allows you to list a set of hosts. The list you can provide is quite flexible. It's using the host expansion algorithm which is used in all places in infra where you can specify a set of hosts. Some of the command-line utilities allow you to specify a list of hosts, but also linking to hosts from spec sections in your resource definitions follow this algorithm. This command helps you to test this. Some examples:

As you can see, you can freely mix and match host names, host group names, and take advantage of hierarchy in host groups.

Executing commands in bulk over SSH

The infra host:exec <hosts> <command> command lets you perform a standard shell command one one or more hosts in bulk.

The first argument is the list of hosts you want to perform the command on (following the host expansion algorithm described earlier), and the second argument is the actual command.

Generating firewall rules

Infra can generate complex firewall configurations based on very simple rule defintions. For example, it allows you to set up a rule that allows access to a specified port from all hosts in group X to all hosts in group Y over public or private IP addresses. It will dynamically generate the required rules based on your infra graph. You can leverage the full power of the host expansion algorithm (described earlier) to specify source and remote target host lists.

Run infra firewall:show <hosts> (or short-hand notation infra f:s <hosts>) to let infra generate firewall rules for the specified host.

Running infra f:s db0m will output the generated iptables rules to the console like this:

Compare these to the definitions in example/resources/FirewallRule/;

Note how you'll find rules defined for both the "db" hostgroup (of which db0m is a direct member), and rules for the "prod" hostgroup (of which db0m is only indirectly a member through the "prod" child hostgroup "prod-east").

Additionally, you'll notice that the db0m server has 2 rules generated for the 2 app servers (app1 and app2). In case you'll add 5 more app servers, infra will automatically generate a rule for each of them (7 in total).

Installing firewall rules

Run infra firewall:install <hosts> to install the firewall. Infra will ssh into the host(s) and:

  1. backup the current iptable rules using iptables-save. The backup is created in /tmp, and the exact filename will be displayed on the console.
  2. Copy the firewall rules to the server
  3. Run iptables-restore on the rules file and output the results.

Scripts (in your language of choice)

If you'd like to build tools that leverage your infrastructure graph in your language of choice (php, node, python, ruby, bash, etc), scripts are your solution.

Creating your own script

To create your own custom script:

  1. Add an executable script in the scripts/ directory of your infrastructure configuration repository
  2. Make sure to chmod 755 the file, as only executable files are detected by infra
  3. Let your script execute GraphQL queries using the infra query command (pass in the query over stdin, getting the response json from stdout)
  4. Use the returned data to apply any logic you see fit: export to common config formats, call a set of APIs, generate documentation, etc.

SDKs

An SDK is not required, but may make your life as an infra script developer more convenient. Currently available SDKs:

Let us know if you've created an SDKs for other languages, we'll be glad to link to it from this section.

Example scripts

Examples are included in the example/scripts directory. (examples in more languages welcomed as PRs!)

Core scripts

A set of "core" scripts are included in the scripts/ directory of this repository. The core scripts are for commonly used applications that will be of use to many infra users. If you've created a reusable script that you'd like to be included in the core scripts, be sure to send a PR!

Todo

License

MIT. Please refer to the license file for details.

Brought to you by the LinkORB Engineering team


Check out our other projects at linkorb.com/engineering.

Btw, we're hiring!


All versions of infra with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
linkorb/infra-sdk Version ^1.0
linkorb/graph Version ^1.0
linkorb/scripter Version ^1.0
symfony/console Version ^4.0
symfony/process Version ^3.0|^4.0
symfony/yaml Version ^3.0|^4.0
twig/twig Version ~1.0
symfony/dotenv Version ^4.0
doctrine/inflector Version ^1.0
ssh-client/ssh-client Version ^0.1
webonyx/graphql-php Version ^0.13.1
geekdevs/cli-highlighter Version ^1.0.3
symfony/serializer Version ^4.2
php-http/guzzle6-adapter Version ^1.1
knplabs/github-api Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package linkorb/infra contains the following files

Loading the files please wait ....