mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-27 19:51:41 +00:00
Clarified Ansible installation instructions and added slacknotification.py script.
This commit is contained in:
@ -34,12 +34,25 @@ The cloud inventory scripts come from the ansible team at their [GitHub](https:/
|
|||||||
|
|
||||||
Ansible requires a "command machine" or "local machine" or "orchestrator machine" to run on. This can be your laptop or any machine that runs linux. (It does not have to be part of the cloud network that hosts your servers.)
|
Ansible requires a "command machine" or "local machine" or "orchestrator machine" to run on. This can be your laptop or any machine that runs linux. (It does not have to be part of the cloud network that hosts your servers.)
|
||||||
|
|
||||||
Note: All the below commands use the Ubuntu/Debian `apt-get` command. To make it compatible with RedHat/CentOS, replace it with `yum`.
|
Use the official [Ansible installation guide](http://docs.ansible.com/ansible/intro_installation.html) to install Ansible. Here are a few examples on basic installation commands:
|
||||||
|
|
||||||
|
Ubuntu/Debian:
|
||||||
```
|
```
|
||||||
sudo apt-get install ansible
|
sudo apt-get install ansible
|
||||||
```
|
```
|
||||||
|
|
||||||
|
CentOS/RedHat:
|
||||||
|
```
|
||||||
|
sudo yum install epel-release
|
||||||
|
sudo yum install ansible
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac OSX:
|
||||||
|
```
|
||||||
|
sudo easy_install pip
|
||||||
|
sudo pip install ansible
|
||||||
|
```
|
||||||
|
|
||||||
To make life easier, you can start an SSH Agent and load your SSH key(s). This way ansible will have an uninterrupted way of connecting to your servers.
|
To make life easier, you can start an SSH Agent and load your SSH key(s). This way ansible will have an uninterrupted way of connecting to your servers.
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -55,17 +68,42 @@ Subsequently, as long as the agent is running, you can use `source ~/.ssh/ssh.en
|
|||||||
|
|
||||||
If you are using a cloud provider to host your servers, you need the below dependencies installed on your local machine.
|
If you are using a cloud provider to host your servers, you need the below dependencies installed on your local machine.
|
||||||
|
|
||||||
DigitalOcean inventory dependencies:
|
#### DigitalOcean inventory dependencies:
|
||||||
|
|
||||||
|
Ubuntu/Debian:
|
||||||
```
|
```
|
||||||
sudo apt-get install python-pip
|
sudo apt-get install python-pip
|
||||||
sudo pip install dopy
|
sudo pip install dopy
|
||||||
```
|
```
|
||||||
|
|
||||||
|
CentOS/RedHat:
|
||||||
|
```
|
||||||
|
sudo yum install python-pip
|
||||||
|
sudo pip install dopy
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac OSX:
|
||||||
|
```
|
||||||
|
sudo pip install dopy
|
||||||
|
```
|
||||||
|
|
||||||
Amazon AWS inventory dependencies:
|
Amazon AWS inventory dependencies:
|
||||||
|
|
||||||
|
Ubuntu/Debian:
|
||||||
```
|
```
|
||||||
sudo apt-get install python-boto
|
sudo apt-get install python-boto
|
||||||
```
|
```
|
||||||
|
|
||||||
|
CentOS/RedHat:
|
||||||
|
```
|
||||||
|
sudo yum install python-boto
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac OSX:
|
||||||
|
```
|
||||||
|
sudo pip install boto
|
||||||
|
```
|
||||||
|
|
||||||
## Refreshing the DigitalOcean inventory
|
## Refreshing the DigitalOcean inventory
|
||||||
|
|
||||||
If you just finished creating droplets, the local DigitalOcean inventory cache is not up-to-date. To refresh it, run:
|
If you just finished creating droplets, the local DigitalOcean inventory cache is not up-to-date. To refresh it, run:
|
||||||
|
16
devops/README.md
Normal file
16
devops/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# DevOps tools
|
||||||
|
|
||||||
|
This folder contains tools that are used for automated testnet deployments.
|
||||||
|
|
||||||
|
## slacknotification.py
|
||||||
|
|
||||||
|
A small script that can send Slack messages.
|
||||||
|
|
||||||
|
Requirements: slackclient python library
|
||||||
|
|
||||||
|
Install slackclient by running as root:
|
||||||
|
```
|
||||||
|
pip install slackclient
|
||||||
|
```
|
||||||
|
|
||||||
|
|
41
devops/slacknotification.py
Normal file
41
devops/slacknotification.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import os
|
||||||
|
from slackclient import SlackClient
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description="Slack notification script")
|
||||||
|
parser.add_argument('--channel','-c', required=True, help="Slack channel.")
|
||||||
|
parser.add_argument('--message','-m', required=True, help="The message to send.")
|
||||||
|
parser.add_argument('--username', required=False, help="Username used on Slack")
|
||||||
|
parser.add_argument('--api_token', required=False, help="Slack API token. Can be set in SLACK_API_TOKEN environment variable too.")
|
||||||
|
parser.add_argument('--icon_emoji','-i', required=False, help="Icon for the message.")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
username = args.username
|
||||||
|
api_token=args.api_token
|
||||||
|
if api_token is None:
|
||||||
|
api_token=os.getenv("SLACK_API_TOKEN")
|
||||||
|
message = args.message
|
||||||
|
channel = args.channel
|
||||||
|
icon_emoji = args.icon_emoji
|
||||||
|
|
||||||
|
slack_client = SlackClient(api_token)
|
||||||
|
apitest = slack_client.api_call("api.test")
|
||||||
|
if not apitest['ok']:
|
||||||
|
raise ValueError("api.test error: {0}".format(apitest['error']))
|
||||||
|
|
||||||
|
authtest = slack_client.api_call("auth.test")
|
||||||
|
if not authtest['ok']:
|
||||||
|
raise ValueError("auth.test error: {0}".format(authtest['error']))
|
||||||
|
|
||||||
|
if username is None:
|
||||||
|
username = authtest['user']
|
||||||
|
|
||||||
|
if icon_emoji is None:
|
||||||
|
result = slack_client.api_call("chat.postMessage", channel=channel, text=message, username=username, icon_emoji=icon_emoji)
|
||||||
|
else:
|
||||||
|
result = slack_client.api_call("chat.postMessage", channel=channel, text=message, username=username)
|
||||||
|
|
||||||
|
if not result['ok']:
|
||||||
|
raise ValueError("Message error: {0}".format(result['error']))
|
||||||
|
|
Reference in New Issue
Block a user