From 3a7d2a3378792e2940583e3106659a373d12fc24 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Wed, 3 Jul 2019 18:10:34 +0200 Subject: [PATCH] Init repo --- .gitignore | 8 ++++ LICENSE | 21 ++++++++++ README.md | 24 ++++++++++++ hosts | 2 + main.yml | 13 +++++++ play | 2 + roles/config/files/bash_aliases | 27 +++++++++++++ roles/config/files/emacs | 5 +++ roles/config/tasks/main.yml | 22 +++++++++++ roles/packages/tasks/main.yml | 4 ++ roles/packages/vars/main.yml | 59 +++++++++++++++++++++++++++++ roles/ssh/files/jochen@klarbook.pub | 1 + roles/ssh/files/jochen@klarpc.pub | 1 + roles/ssh/handlers/main.yml | 3 ++ roles/ssh/tasks/main.yml | 12 ++++++ 15 files changed, 204 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 hosts create mode 100644 main.yml create mode 100755 play create mode 100644 roles/config/files/bash_aliases create mode 100644 roles/config/files/emacs create mode 100644 roles/config/tasks/main.yml create mode 100644 roles/packages/tasks/main.yml create mode 100644 roles/packages/vars/main.yml create mode 100644 roles/ssh/files/jochen@klarbook.pub create mode 100644 roles/ssh/files/jochen@klarpc.pub create mode 100644 roles/ssh/handlers/main.yml create mode 100644 roles/ssh/tasks/main.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..13e5522 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +__pycache__ +*.pyc +*~ +*- +*.swp +.DS_Store + +env diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0b83fa --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Potsdam Institute for Climate Impact Research + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c5a508 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +Ansible playbook for data.isimip.org and files.isimip.org +========================================================= + +This software is currently under development. + +Setup +----- + +```bash +python3 -m venv env +source env/bin/activate +pip install pip ansible +``` + + +Usage +----- + +```bash +./play +./play -l data.isimip.org +./play -l files.isimip.org +./play -t config +``` diff --git a/hosts b/hosts new file mode 100644 index 0000000..b2e999f --- /dev/null +++ b/hosts @@ -0,0 +1,2 @@ +data.isimip.org +files.isimip.org diff --git a/main.yml b/main.yml new file mode 100644 index 0000000..4774dfe --- /dev/null +++ b/main.yml @@ -0,0 +1,13 @@ +--- + +- name: all hosts + hosts: all + become: yes + become_user: root + roles: + - role: config + tags: ['config'] + - role: ssh + tags: ['ssh'] + - role: packages + tags: ['packages'] diff --git a/play b/play new file mode 100755 index 0000000..e568cfa --- /dev/null +++ b/play @@ -0,0 +1,2 @@ +#!/bin/bash +ansible-playbook -i hosts $@ main.yml diff --git a/roles/config/files/bash_aliases b/roles/config/files/bash_aliases new file mode 100644 index 0000000..c27b1b4 --- /dev/null +++ b/roles/config/files/bash_aliases @@ -0,0 +1,27 @@ +alias ls='ls --color=auto' +alias ll='ls -lah' + +alias e='emacs' +alias h='history' +alias p='python' +alias t='tail -f' +alias grep='grep --color' + +alias gits='git status' +alias gita='git add .' +alias gitc='git commit -am' +alias gitl='git log' +alias gitb='git branch' +alias gitd='git diff' +alias gitu='git diff | grep -C 3 -f ~/.gitunwanted' + +alias sv='service' +alias sd='sudo -i' +alias ap='aptitude' + +alias ve='source env/bin/activate' +alias ve3='source env3/bin/activate' +alias de='deactivate' + +alias psg='ps auxw | grep --color' +alias eng='env | grep --color' diff --git a/roles/config/files/emacs b/roles/config/files/emacs new file mode 100644 index 0000000..ccb1de5 --- /dev/null +++ b/roles/config/files/emacs @@ -0,0 +1,5 @@ +(line-number-mode t) +(column-number-mode t) + +(setq make-backup-files nil) +(setq-default indent-tabs-mode nil) diff --git a/roles/config/tasks/main.yml b/roles/config/tasks/main.yml new file mode 100644 index 0000000..f360b99 --- /dev/null +++ b/roles/config/tasks/main.yml @@ -0,0 +1,22 @@ +--- + +- name: red prompt for root + lineinfile: dest=/root/.bashrc line="export PS1='[\[\e[0;31m\]\u@\h\[\e[0m\] \W]\$ '" + +- name: include .bash_aliases in /root/.bashrc + lineinfile: dest=/root/.bashrc line="source /root/.bash_aliases" + +- name: /root/.bash_aliases + copy: src=bash_aliases dest=/root/.bash_aliases + +- name: /root/.emacs + copy: src=emacs dest=/root/.emacs + +- name: include .bash_aliases in /home/ubuntu/.bashrc + lineinfile: dest=/home/ubuntu/.bashrc line="source /home/ubuntu/.bash_aliases" + +- name: /home/ubuntu/.bash_aliases + copy: src=bash_aliases dest=/home/ubuntu/.bash_aliases + +- name: /home/ubuntu/.emacs + copy: src=emacs dest=/home/ubuntu/.emacs diff --git a/roles/packages/tasks/main.yml b/roles/packages/tasks/main.yml new file mode 100644 index 0000000..30b6856 --- /dev/null +++ b/roles/packages/tasks/main.yml @@ -0,0 +1,4 @@ +--- + +- name: common packages are present + apt: name="{{ packages }}" state=present diff --git a/roles/packages/vars/main.yml b/roles/packages/vars/main.yml new file mode 100644 index 0000000..bbf7e91 --- /dev/null +++ b/roles/packages/vars/main.yml @@ -0,0 +1,59 @@ +--- +packages: +- aptitude +- sudo +- pwgen +- screen +- fail2ban +- rsync + +# editor +- vim +- nano +- emacs-nox + +# development +- build-essential +- cmake +- git +- subversion + +# compression +- zip +- unzip +- bzip2 + +# monitoring +- strace +- dstat +- htop +- iotop +- iftop +- glances +- iperf3 +- iftop +- ncdu + +# network +- telnet +- wget +- curl +- nmap + +# hardware +- smartmontools +- pciutils +- ethtool +- lsscsi +- sysstat +- pv +- lsof +- inxi + +# python +- python3-dev +- python3-pip +- python3-venv + +# other +- silversearcher-ag diff --git a/roles/ssh/files/jochen@klarbook.pub b/roles/ssh/files/jochen@klarbook.pub new file mode 100644 index 0000000..ab383ad --- /dev/null +++ b/roles/ssh/files/jochen@klarbook.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCx+ffDErCmljYWvVAjPVKUHyjVJTZaSgdImNeyl0XBt5R5LRXBqp6TCigEIEfvz4do5nglZwOiKfNhaNH/+opBv5AQ0chYWlLK+jNlzkZZ4T2tXXpW4iIMq9gr1CpA1HatHndaDLyB6bG7vHakXufNsPNiVf2+pdB1VtgdyASmFEnf5R8CEhqUy8ciKXB0Ko8QxKD7gNYEVNWKvD+GRKFm1+9xD/OwXC2Sew+9MIjuZDLo9sXMhuZGrQdDe9ybq6yJgXQwjSI8hyms9WEQZKem8dairnOUhxTmM24erdQdfy6rWHeIkLIX5ZfbfCQuhLRWbtPcx1plgqEktqp2ufANJxtCB3+gYkEi17HSYWmRzR2giWqNCldE5VhPBFVFMjcnblX91D0mJfdKmqI5DoY7zL0E1RuuzwPYviCTpcol6a+ruxVK/igTPB0CCg0HvDvtg6rM/OMIxN3zwZA1jnpBBFcyIvv/2rHMgJAL1FIsWzGr5/uwD7Us/vrr1vUZFcd+yvrEY26yZ3yqOGPr33I14xdfc+lNY3c6GPhRdWz7IboVN+EhK83n1aAyV0uivZ2/432EIgIlsTilHI2XpHY6EkH2YstZunB0+UJSFnyhDvd2oAL+rcqtNM+heGj+f2PMqBmrsA1mrQRiBp85EXQJ9ssw9KyIdMX/y6fXSIEygw== jochen@klarbook \ No newline at end of file diff --git a/roles/ssh/files/jochen@klarpc.pub b/roles/ssh/files/jochen@klarpc.pub new file mode 100644 index 0000000..450fc31 --- /dev/null +++ b/roles/ssh/files/jochen@klarpc.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCnXRAVdcQ9sneyRDnn1qVUc9wpuee1e8JT+5XBYeKdSbQ0Usnn6MCfjGsErp3e4v6pCTmwwjU0SzPq5UBA3kvTI4hDO6He4CtdR1Pbgf/Z37x6XVyD6Cu05p+vgLhsNjPevOxbKNtzxuXdFn0OahpvMQ+mS1QLe7f4mwrSMa+AixfnxK6howMj2Kg1N6tfIDZeG5JB9RwFvx6V+hAK4Ge0xQXaWuwmLlwW7l48Or80hS60VGGUcGG3v6qfTgUJLoLH/pdOgHFeK8G+1/1LKzesqziBn1nBJPrw4AilIF0i7myKBcUkllYPlSSbjmC7YLEV2pVPZmphi8JUCnrgFnNZ0/0SwMUiFA2Waz+xL7cEfHzgxqS4fRWgywLkZUxvX2mz5hmQy6mQBrCuoU2euGf5IV9arcNmiFfhZXiAWGClnqN6Cf3hRRHR4EhZWlZfBjMmACti8oe+ozizxVCh0Py2t9ZlUa7GI2fa27a0gxyva5Dc0PHhreofkPcFaj07ZUlaqkj6xpA2c4Aw6DOlHKQ65ODfv7eQYBCfC2DwM3Uv/92OFGILdOpIMuruMcSzh6xNtDMYke5yNiTgZnQtJfpEOJ1uIjLrDu+vmYCm4SS2tRykb1zU87MhdJhekBISguTuM4alCnpDRyPnR2tEqOBmfl+M/Cf7F7w63a5DCBY12Q== jochen@klarpc \ No newline at end of file diff --git a/roles/ssh/handlers/main.yml b/roles/ssh/handlers/main.yml new file mode 100644 index 0000000..6126543 --- /dev/null +++ b/roles/ssh/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart ssh + service: name=ssh state="restarted" diff --git a/roles/ssh/tasks/main.yml b/roles/ssh/tasks/main.yml new file mode 100644 index 0000000..a000680 --- /dev/null +++ b/roles/ssh/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: ssh keys for root + authorized_key: user=root key="{{ item }}" state=present + with_file: + - jochen@klarpc.pub + - jochen@klarbook.pub + +- name: ssh keys for ubuntu + authorized_key: user=ubuntu key="{{ item }}" state=present + with_file: + - jochen@klarpc.pub + - jochen@klarbook.pub