# shipit-conditional

> This package adds support for running tasks only on certain hosts in the server list

Latest version **0.0.3** (published 2019-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install shipit-conditional
pnpm add shipit-conditional
yarn add shipit-conditional
bun add shipit-conditional
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-03-06 |
| First published | 2019-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 2 |
| Unpacked size | 12.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Brokerage Engine, Inc |
| Maintainers | brokerageengine |
| Keywords | shipit, automation, deployment, bastion, proxy, forwardAgent, proxyCommand, ssh |

## Links

- npm: https://www.npmjs.com/package/shipit-conditional
- Repository: https://github.com/BrokerageEngine/shipit-conditional
- Homepage: https://github.com/BrokerageEngine/shipit-conditional#readme
- Issues: https://github.com/BrokerageEngine/shipit-conditional/issues
- npm.io page: https://npm.io/package/shipit-conditional

## Dependencies (2)

- [shipit-utils](https://npm.io/package/shipit-utils.md) ^1.4.1
- [ssh-proxy-pool](https://npm.io/package/ssh-proxy-pool.md) ^0.0.4

## Recent versions

- 0.0.3 (latest) — 2019-03-06
- 0.0.2 — 2019-02-28
- 0.0.1 — 2019-02-28

## README

# shipit-conditional

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

**Restrict certain tasks to certain servers** ✨

You may have situations where you only want to deploy to servers matching certain criteria. 
For example, you may have changed some aspect of how the web role works, but don’t want to trigger a deployment to your database servers.

originally inspired by [Capistrano](https://capistranorb.com/documentation/advanced-features/role-filtering/)

**** Currently this requires shipit-bastion as well ***

The methods needed in the ssh pool are part of ssh-proxy-pool. Currently that means you need to include shipit-bastion before this plugin to use it.

# Features

The server configuration in shipit will take an object.

```js
  servers: [
        {
          user: "be",
          host: "www.brokerageengine.com",
          roles: ["app", "db"]
        }
      ]
```

By setting these flags you can define a method like following to be true if the server is a dbServer

```js
(connection) =>connection.dbServer === true
```

The plugin adds 

* shipit.remoteWithCondition
* shipit.remoteCopyWithCondition
* shipit.copyToRemoteWithCondition
* shipit.copyFromRemoteWithCondition 

Each of them takes a condition function as the first argument

```js
shipit.remoteWithCondition((condition => (connection.dbServer === true ), "pwd"))
```
```js
shipit.copyToRemoteWithCondition((condition => (connection.appServer === true ), "/tmp/local.txt", "/tmp/remote.txt"))
```
```js
const isRole = ( role) =>  (connection) => connection.options &&
    connection.options.remote &&
    connection.options.remote.roles &&
    connection.options.remote.roles.includes(role)
  const isAppServer = isRole("app")
  const isDBServer = isRole("db")
   
  
 
  shipit.task("pwd",async  function() {
    //Gets pwd for all app servers
   const result = await shipit.remoteWithCondition(isAppServer, "pwd")
   //Gets the /tmp only for the db server
   const result2 = await shipit.remoteWithCondition(isDBServer, "ls -l /tmp")
  });
};
```
# License

MIT © 2019 Brokerage Engine, Inc

---
_Source: https://npm.io/package/shipit-conditional · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
