Skip to content

Instantly share code, notes, and snippets.

View alexcheng1982's full-sized avatar
๐ŸŽ‰
AI time

Fu Cheng alexcheng1982

๐ŸŽ‰
AI time
View GitHub Profile
@alexcheng1982
alexcheng1982 / install-app.yml
Created December 14, 2017 19:30
Install app
- name: install app
win_package:
path: "{{ exe_find.files[0].path }}"
arguments: "-q -overwrite -varfile {{ app.install_varfile_path }}"
product_id: {{ app.product_id }}
state: present
creates_path: Z:\app
@alexcheng1982
alexcheng1982 / app-roles.yml
Created December 14, 2017 19:30
Install app with roles
- name: install app
hosts: dev
gather_facts: no
vars_files:
- secret.yml
roles:
- aws
- app
@alexcheng1982
alexcheng1982 / config-firewall.ps1
Created December 14, 2017 19:31
Configure firewall
netsh advfirewall firewall add rule name="App Port 8080" dir=in action=allow protocol=TCP localport=8080
@alexcheng1982
alexcheng1982 / install-app-passing-variables.yml
Created December 14, 2017 19:32
Pass variables between hosts
- name: install app
hosts: dev
gather_facts: no
vars:
ip: "{{ hostvars.localhost.ec2.tagged_instances[0].private_ip }}"
vars_files:
- secret.yml
roles:
- aws
- app
@alexcheng1982
alexcheng1982 / hubot-stub-code.sh
Created December 17, 2017 21:12
Hubot stub code
$ yarn global add generator-hubot
$ cd bot
$ yo hubot
@alexcheng1982
alexcheng1982 / hubot-dependencies.json
Created December 17, 2017 21:13
Hubot dependencies
"dependencies": {
"coffee-script": "^1.12.7",
"hubot": "^2.19.0",
"hubot-help": "^0.2.2",
"hubot-hipchat": "^2.12.0-6",
"hubot-scripts": "^2.17.2"
}
@alexcheng1982
alexcheng1982 / external-scripts.json
Created December 17, 2017 21:13
Hubot external-scripts.json
[
"hubot-help"
]
@alexcheng1982
alexcheng1982 / ops.js
Created December 17, 2017 21:14
Hubot handler
const yargs = require('yargs');
const spawn = require('child_process').spawn;
module.exports = (robot) => {
robot.respond(/deploy (.*)/i, (res) => {
let parser = yargs.command('deploy <build_num>', 'deploy a version', (yargs) => {
yargs
.positional('build_num', {
describe: 'build number',
})
@alexcheng1982
alexcheng1982 / Dockerfile
Created December 17, 2017 21:15
Hubot Dockerfile
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
# gpg keys listed at https://github.com/nodejs/node#release-team
RUN set -ex \
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
@alexcheng1982
alexcheng1982 / check-instances.js
Created December 19, 2017 20:02
AWS Lambda check instances
function findTag(tags, key) {
for (var i = tags.length - 1; i >= 0; i--) {
if (tags[i].Key === key) {
return tags[i].Value;
}
}
}
exports.handler = (event, context, callback) => {
var AWS = require('aws-sdk');