2
0
mirror of https://github.com/frappe/bench.git synced 2025-02-13 08:18:27 +00:00

added ansible playbooks

This commit is contained in:
nginn 2015-12-25 18:33:21 +03:00
parent 35f632154d
commit 4645b604c8
30 changed files with 790 additions and 0 deletions

View File

@ -0,0 +1,7 @@
---
- hosts: local
sudo: true
roles:
- add_repos
- install_packages

View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for add_repos

View File

@ -0,0 +1,8 @@
#!/bin/bash
echo "[mariadb]" > $1
echo "name = MariaDB" >> $1
OS_VER=`cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d" " -f3 | cut -d. -f1`
ARCH=`uname -m | sed 's/x86_/amd/;s/i[3-6]86/x86/'`
echo "baseurl = http://yum.mariadb.org/10.0/centos$OS_VER-$ARCH" >> $1
echo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" >> $1
echo "gpgcheck=1" >> $1

View File

@ -0,0 +1,2 @@
---
# handlers file for add_repos

View File

@ -0,0 +1,139 @@
---
galaxy_info:
author: your name
description:
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
#
# Below are all platforms currently available. Just uncomment
# the ones that apply to your role. If you don't see your
# platform on this list, let us know and we'll get it added!
#
#platforms:
#- name: EL
# versions:
# - all
# - 5
# - 6
# - 7
#- name: GenericUNIX
# versions:
# - all
# - any
#- name: Fedora
# versions:
# - all
# - 16
# - 17
# - 18
# - 19
# - 20
# - 21
# - 22
#- name: Windows
# versions:
# - all
# - 2012R2
#- name: SmartOS
# versions:
# - all
# - any
#- name: opensuse
# versions:
# - all
# - 12.1
# - 12.2
# - 12.3
# - 13.1
# - 13.2
#- name: Amazon
# versions:
# - all
# - 2013.03
# - 2013.09
#- name: GenericBSD
# versions:
# - all
# - any
#- name: FreeBSD
# versions:
# - all
# - 8.0
# - 8.1
# - 8.2
# - 8.3
# - 8.4
# - 9.0
# - 9.1
# - 9.1
# - 9.2
#- name: Ubuntu
# versions:
# - all
# - lucid
# - maverick
# - natty
# - oneiric
# - precise
# - quantal
# - raring
# - saucy
# - trusty
# - utopic
# - vivid
#- name: SLES
# versions:
# - all
# - 10SP3
# - 10SP4
# - 11
# - 11SP1
# - 11SP2
# - 11SP3
#- name: GenericLinux
# versions:
# - all
# - any
#- name: Debian
# versions:
# - all
# - etch
# - jessie
# - lenny
# - squeeze
# - wheezy
#
# Below are all categories currently available. Just as with
# the platforms above, uncomment those that apply to your role.
#
#categories:
#- cloud
#- cloud:ec2
#- cloud:gce
#- cloud:rax
#- clustering
#- database
#- database:nosql
#- database:sql
#- development
#- monitoring
#- networking
#- packaging
#- system
#- web
dependencies: []
# List your role dependencies here, one per line.
# Be sure to remove the '[]' above if you add dependencies
# to this list.

View File

@ -0,0 +1,61 @@
---
# tasks file for add_repos
#- hosts: local
# tasks:
- name: "Transfer script for .repo creation to /tmp"
copy: src=create_mariadb_repo_centos.sh dest=/tmp mode=0777
when: (ansible_distribution == "CentOS")
- name: "Filling in mariadb.repo file"
command: /tmp/create_mariadb_repo_centos.sh /tmp/mariadb.repo
when: (ansible_distribution == "CentOS")
- name: "Place mariadb.repo file in system dir"
command: mv /tmp/mariadb.repo /etc/yum.repos.d/
when: (ansible_distribution == "CentOS")
- name: "Clean files in tmp"
command: rm /tmp/create_mariadb_repo_centos.sh
when: (ansible_distribution == "CentOS")
- name: "Installing epel rpm for CentOS 6"
yum: name=http://dl.iuscommunity.org/pub/ius/stable/CentOS/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/epel-release-6-5.noarch.rpm state=present
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6")
- name: "Installing ius rpm for CentOS 6"
yum: name=http://dl.iuscommunity.org/pub/ius/stable/CentOS/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/ius-release-1.0-14.ius.centos6.noarch.rpm state=present
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6")
- name: "Install epel for CentOS 7"
yum: name=epel-release state=present
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "7")
- name: "Update repository cache Debian/Ubuntu"
apt: update_cache=yes
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
- name: "Install software properties Debian"
apt: name=software-properties-common
when: (ansible_distribution == "Debian")
- name: "Install python software properties Debian"
apt: name=python-software-properties
when: (ansible_distribution == "Debian")
- name: "Receive key Debian/Ubuntu"
apt_key: keyserver=keyserver.ubuntu.com id=0xcbcb082a1bb943db
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
- name: "Add MariaDB repo Debian"
apt_repository: repo="deb http://ams2.mirrors.digitalocean.com/mariadb/repo/10.0/debian {{ ansible_distribution_release }} main"
when: (ansible_distribution == "Debian" and ansible_distribution_major_version >= 6)
- name: "Add MariaDB repo Ubuntu"
apt_repository: repo="deb http://ams2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu {{ ansible_distribution_version }} main"
when: (ansible_distribution == "Ubuntu")
- name: "Install Nodesource Node.js repo Debian"
shell: curl -sL https://deb.nodesource.com/setup_0.12 | bash -
when: (ansible_distribution == "Debian")

View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for install_packages

View File

@ -0,0 +1,11 @@
#!/bin/bash
echo "[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4" > $1

View File

@ -0,0 +1,2 @@
---
# handlers file for install_packages

View File

@ -0,0 +1,139 @@
---
galaxy_info:
author: your name
description:
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
#
# Below are all platforms currently available. Just uncomment
# the ones that apply to your role. If you don't see your
# platform on this list, let us know and we'll get it added!
#
#platforms:
#- name: EL
# versions:
# - all
# - 5
# - 6
# - 7
#- name: GenericUNIX
# versions:
# - all
# - any
#- name: Fedora
# versions:
# - all
# - 16
# - 17
# - 18
# - 19
# - 20
# - 21
# - 22
#- name: Windows
# versions:
# - all
# - 2012R2
#- name: SmartOS
# versions:
# - all
# - any
#- name: opensuse
# versions:
# - all
# - 12.1
# - 12.2
# - 12.3
# - 13.1
# - 13.2
#- name: Amazon
# versions:
# - all
# - 2013.03
# - 2013.09
#- name: GenericBSD
# versions:
# - all
# - any
#- name: FreeBSD
# versions:
# - all
# - 8.0
# - 8.1
# - 8.2
# - 8.3
# - 8.4
# - 9.0
# - 9.1
# - 9.1
# - 9.2
#- name: Ubuntu
# versions:
# - all
# - lucid
# - maverick
# - natty
# - oneiric
# - precise
# - quantal
# - raring
# - saucy
# - trusty
# - utopic
# - vivid
#- name: SLES
# versions:
# - all
# - 10SP3
# - 10SP4
# - 11
# - 11SP1
# - 11SP2
# - 11SP3
#- name: GenericLinux
# versions:
# - all
# - any
#- name: Debian
# versions:
# - all
# - etch
# - jessie
# - lenny
# - squeeze
# - wheezy
#
# Below are all categories currently available. Just as with
# the platforms above, uncomment those that apply to your role.
#
#categories:
#- cloud
#- cloud:ec2
#- cloud:gce
#- cloud:rax
#- clustering
#- database
#- database:nosql
#- database:sql
#- development
#- monitoring
#- networking
#- packaging
#- system
#- web
dependencies: []
# List your role dependencies here, one per line.
# Be sure to remove the '[]' above if you add dependencies
# to this list.

View File

@ -0,0 +1,7 @@
---
- name: "Transfer script to tmp"
copy: src=create_mariadb_config.sh dest=/tmp mode=0777
- name: "Create MariaDB configuration"
command: /tmp/create_mariadb_config.sh /etc/my.cnf.d/barracuda.cnf

View File

@ -0,0 +1,8 @@
---
- name: "Transfer script to tmp"
copy: src=create_mariadb_config.sh dest=/tmp mode=0777
- name: "Create MariaDB configuration"
command: /tmp/create_mariadb_config.sh /etc/mysql/conf.d/barracuda.cnf

View File

@ -0,0 +1,11 @@
---
- shell: chkconfig --add supervisord
- shell: chkconfig redis on
- shell: chkconfig mysql on
- shell: chkconfig nginx on
- shell: chkconfig supervisord on

View File

@ -0,0 +1,9 @@
---
- service: name=nginx enabled=yes
- service: name=mariadb enabled=yes
- service: name=redis enabled=yes
- service: name=supervisord enabled=yes

View File

@ -0,0 +1,33 @@
---
- name: "Install packages list for CentOS 6"
yum: pkg={{ item }} state=installed
with_items:
- git
- MariaDB-server
- MariaDB-client
- MariaDB-compat
- python-setuptools
- nginx
- zlib-devel
- bzip2-devel
- openssl-devel
- postfix
- python27-devel
- python27
- libxml2
- libxml2-devel
- libxslt
- libxslt-devel
- redis
- MariaDB-devel
- libXrender
- libXext
- python27-setuptools
- cronie
- sudo
- which
- xorg-x11-fonts-Type1
- xorg-x11-fonts-75dpi
- nodejs
- npm

View File

@ -0,0 +1,38 @@
---
- name: "Install packages list for CentOS 7"
yum: pkg={{ item }} state=installed
with_items:
- git
- mariadb-server
- mariadb-devel
- python-setuptools
- nginx
- zlib-devel
- bzip2-devel
- openssl-devel
- postfix
- python-devel
- libxml2
- libxml2-devel
- libxslt
- libxslt-devel
- redis
- libXrender
- libXext
- supervisor
- cronie
- sudo
- which
- xorg-x11-fonts-75dpi
- xorg-x11-fonts-Type1
- nodejs
- npm
- libtiff-devel
- libjpeg-devel
- libzip-devel
- freetype-devel
- lcms2-devel
- libwebp-devel
- tcl-devel
- tk-devel

View File

@ -0,0 +1,33 @@
---
- name: "Install list of common packages for Debian/Ubuntu"
apt: pkg={{ item }} state=installed
with_items:
- python-dev
- python-setuptools
- build-essential
- python-mysqldb
- git
- ntp
- vim
- screen
- htop
- mariadb-server
- mariadb-common
- libmariadbclient-dev
- libxslt1.1
- libxslt1-dev
- redis-server
- libssl-dev
- libcrypto++-dev
- postfix
- nginx
- supervisor
- fontconfig
- libxrender1
- libxext6
- xfonts-75dpi
- xfonts-base
- nodejs
- npm

View File

@ -0,0 +1,14 @@
---
- name: "Install packages for Debian 8"
apt: pkg={{ item }} state=installed
with_items:
- libtiff5-dev
- libjpeg62-turbo-dev
- zlib1g-dev
- libfreetype6-dev
- liblcms2-dev
- libwebp-dev
- tcl8.5-dev
- tk8.5-dev
- python-tk

View File

@ -0,0 +1,14 @@
---
- name: "Install packages for Ubuntu/Debian except from Precise and 8"
apt: pkg={{ item }} state=installed
with_items:
- libtiff5-dev
- libjpeg8-dev
- zlib1g-dev
- libfreetype6-dev
- liblcms2-dev
- libwebp-dev
- tcl8.6-dev
- tk8.6-dev
- python-tk

View File

@ -0,0 +1,14 @@
---
- name: "Install packages for Ubuntu Precise Pangolin"
apt: pkg={{ item }} state=installed
with_items:
- libtiff4-dev
- libjpeg8-dev
- zlib1g-dev
- libfreetype6-dev
- liblcms2-dev
- libwebp-dev
- tcl8.5-dev
- tk8.5-dev
- python-tk

View File

@ -0,0 +1,17 @@
---
- name: "easy_install suprevisor CentOS 6"
command: easy_install supervisor
- shell: curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-init-jkoppe > /etc/init.d/supervisord
- shell: curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-sysconfig-jkoppe > /etc/sysconfig/supervisord
- shell: curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/supervisord.conf > /etc/supervisord.conf
- shell: mkdir /etc/supervisor.d
- shell: chmod +x /etc/init.d/supervisord
- name: "Start supervisord service CentOS6"
shell: service supervisord start || true

View File

@ -0,0 +1,83 @@
---
# tasks file for install_packages
- name: "Generate frappe password"
shell: echo `cat /dev/urandom | tr -dc "a-zA-Z0-9" | head -c 16`
register: frappe_pass
- name: "Generate password for MariaDB"
shell: echo `cat /dev/urandom | tr -dc "a-zA-Z0-9" | head -c 16`
register: msq_pass
- name: "Generate administrator password"
shell: echo `cat /dev/urandom | tr -dc "a-zA-Z0-9" | head -c 16`
register: admin_pass
- name: "Save frappe password"
shell: echo "frappe password:" > ~/frappe_passwords.txt {{frappe_pass.stdout}} >> ~/frappe_passwords.txt
- name: "Save MariaDB root password"
shell: echo "MariaDB root password:" >> ~/frappe_passwords.txt {{msq_pass.stdout}} >> ~/frappe_passwords.txt
- name: "Save administrator password"
shell: echo "administrator password:" >> ~/frappe_passwords.txt {{admin_pass.stdout}} >> ~/frappe_passwords.txt
- include: setup_debconf.yml
when: (ansible_distribution == "Debian")
- include: install_packages_deb.yml
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
- include: install_packages_precise.yml
when: (ansible_distribution_release == "precise")
- include: install_packages_deb8.yml
when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "8")
- include: install_packages_deb_else.yml
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu") and (ansible_distribution_major_version != "8" and ansible_distribution_release == "precise")
- name: "Install wget CentOS"
when: (ansible_distribution == "CentOS")
yum: name=wget state=present
- name: "Install Development tools CentOS"
when: (ansible_distribution == "CentOS")
yum: name="@Development tools" state=present
- include: install_packages_centos6.yml
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6")
- include: install_packages_centos7.yml
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "7")
- include: install_supervisor_centos6.yml
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6")
- include: configure_services_centos6.yml
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6")
- include: start_services_centos6.yml
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6")
- include: configure_services_centos7.yml
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "7")
- include: start_services_centos7.yml
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "7")
- include: configure_mariadb_deb.yml
when: (ansible_distribution == "Debian")
- include: configure_mariadb_cent.yml
when: (ansible_distribution == "CentOS")
- name: "Restart MariaDB service CentOS"
when: (ansible_distribution == "CentOS")
service: name=mariadb state=restarted
- name: "Restart MariaDB service Debian/Ubuntu"
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
service: name=mysql state=restarted

View File

@ -0,0 +1,12 @@
---
- name: "Debconf postfix"
command: debconf-set-selections <<< "postfix postfix/mailname string `hostname`" debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
environment:
DEBIAN_FRONTEND: noninteractive
- name: "Debconf MariaDB"
command: debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password password {{ msq_pass }}" debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password_again password {{ msq_pass }}"
environment:
DEBIAN_FRONTEND: noninteractive

View File

@ -0,0 +1,7 @@
---
- service: name=nginx state=started
- service: name=mariadb state=started
- service: name=redis state=started

View File

@ -0,0 +1,9 @@
---
- service: name=nginx state=started
- service: name=mariadb state=started
- service: name=redis state=started
- service: name=supervisord state=started

View File

@ -0,0 +1,3 @@
---
#msq_pass: shell MSQ_PASS=$(echo `echo ololo`) echo $MSQ_PASS

View File

@ -0,0 +1,29 @@
---
- hosts: local
sudo: true
vars:
tasks:
- name: "Generate appropriate OS name"
shell: echo {{ ansible_distribution }} | awk '{print tolower($0)}'
register: os_name
- name: "Generate appropriate architecture name"
shell: uname -m | sed 's/x86_/amd/;s/i[3-6]86/x86/'
register: os_arch
- name: "Install wkhtmltopdf CentOS"
when: (ansible_distribution == "CentOS")
yum: name="http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-{{ os_name.stdout }}{{ ansible_distribution_major_version }}-{{ os_arch.stdout }}.rpm"
- name: "Downloading wkhtmltopdf .deb package Debian/Ubuntu"
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
shell: wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-{{ ansible_distribution_release }}-{{ os_arch.stdout }}.deb -O /tmp/wkhtmltopdf.deb
- name: "Installing wkhtmltopdf.deb Debian/Ubuntu"
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
apt: deb=/tmp/wkhtmltopdf.deb state=installed
- name: "Cleaning /tmp/wkhtmltopdf.deb"
when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
shell: rm /tmp/wkhtmltopdf.deb