This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Improved playbooks for creating repository and CI server

  • Loading branch information...
BR0kEN- committed Nov 10, 2015
1 parent aadd69a commit c18b0244f1a11ec2051eee9d8232a153058edd0b

This file was deleted.

Oops, something went wrong.
@@ -3,25 +3,28 @@
gather_facts: no
remote_user: root

vars_files:
- ../config.yml

vars:
project: CHANGE_ME
pear_channels:
- pear.drush.org
pear_packages:
- drush/drush
cibox_apt_packages: []

cibox_composer_drush:
version: 6.*
user: "{{ ansible_ssh_user }}"

apache2_modules:
- rewrite

jenkins_configs:
- jenkins.model.JenkinsLocationConfiguration.xml
- org.jenkinsci.plugins.ghprb.GhprbTrigger.xml
- jobs/{{ project }}_PR_BUILDER/config.xml
- jobs/DEMO/config.xml
- "jenkins.model.JenkinsLocationConfiguration.xml"
- "org.jenkinsci.plugins.ghprb.GhprbTrigger.xml"
- "jobs/{{ project | upper }}_PR_BUILDER/config.xml"
- "jobs/DEMO/config.xml"

protected_folders:
- /var/www/backup
- /var/www/cache
- "{{ webroot }}/cache"
- "{{ webroot }}/backup"

protected_folders_user: propeople
protected_folders_pass: givemebackup
@@ -52,16 +55,17 @@
register: allmy
tags: ["cibox-jenkins"]

- name: Adding jenkins user to group shadow
user: name=jenkins groups=shadow append=yes
tags: ["cibox-jenkins"]

- name: Adding jenkins user to group adm
user: name=jenkins groups=adm append=yes
- name: Adding jenkins user to permitted groups
user:
name: jenkins
groups: shadow,adm
append: yes
tags: ["cibox-jenkins"]

- name: Adding jenkins user to nopasswd sudoers
lineinfile: dest=/etc/sudoers line="jenkins ALL=(ALL) NOPASSWD:ALL"
lineinfile:
dest: /etc/sudoers
line: "jenkins ALL=(ALL) NOPASSWD:ALL"
tags: ["cibox-jenkins"]

- name: Install apt packages
@@ -99,15 +103,15 @@
- role: ansible-role-php
tags: ["php-stack"]

- role: ansible-php-pear
tags: ["ansible-php-pear", "php-stack"]

- role: ansible-role-php-xhprof
tags: ["ansible-php-xhprof", "php-stack"]

- role: ansible-composer
tags: ["ansible-composer", "php-stack"]

- role: cibox-composer-drush
tags: ["ansible-composer", "php-stack", "drush"]

- role: ansible-role-mysql
tags: ["mysql", "php-stack", "ansible-role-mysql"]

@@ -131,9 +135,9 @@

tasks:
# @todo More smart way to upload jobs. Move job names to options.
- name: Check if job already renamed.
- name: Check if job already renamed
stat:
path: "/var/lib/jenkins/jobs/{{ project }}_PR_BUILDER"
path: "/var/lib/jenkins/jobs/{{ project | upper }}_PR_BUILDER"
register: prbuilder_stat
tags: ["cibox-jenkins"]

@@ -147,7 +151,7 @@
when: not prbuilder_stat.stat.exists
tags: ["cibox-jenkins"]

- name: Change owner for jenkins files.
- name: Change owner for jenkins files
file:
path: /var/lib/jenkins
owner: jenkins
@@ -157,13 +161,13 @@
recurse: yes
tags: ["cibox-jenkins"]

- name: Rename jenkins jobs to meet project name.
- name: Rename jenkins jobs to meet project name
sudo: yes
shell: "mv /var/lib/jenkins/jobs/PR_BUILDER /var/lib/jenkins/jobs/{{ project }}_PR_BUILDER"
shell: "mv /var/lib/jenkins/jobs/PR_BUILDER /var/lib/jenkins/jobs/{{ project | upper }}_PR_BUILDER"
when: not prbuilder_stat.stat.exists
tags: ["cibox-jenkins"]

- name: Remove PR_BUILDER from remote.
- name: Remove PR_BUILDER from remote
sudo: yes
file:
path: /var/lib/jenkins/jobs/PR_BUILDER
@@ -0,0 +1,64 @@
---
- hosts: localhost
connection: local
gather_facts: no

vars:
# As name of folder inside of "cmf/".
cmf: drupal
# As name of folder inside of "cmf/<NAME>/"
version: 7

vars_files:
- ../config.yml

tasks:
- include: tasks/project-variable.yml

- name: Check for CMF configuration
stat:
path: "../cmf/{{ cmf }}/{{ version }}/"
register: cmf_configs

- name: CMF is not available
fail:
msg: 'You are not allowed to install the "{{ cmf }}" CMF because it is not pre-configured.'
when: not cmf_configs.stat.exists

# @todo Fix to tasks/download-{{ cmf }}.yml in Ansible 2.0
- include: tasks/download/drupal.yml
when: cmf == "drupal"

- name: Prepare CIBox-structured repository
synchronize:
src: "{{ item.src }}"
dest: "../{{ project }}/{{ item.dest | default('') }}"
archive: no
recursive: yes
with_items:
- src: "{{ cmf_configs.stat.path }}/"
- src: "../ansible.sh"
- src: "../config.yml"
- src: "../inventory"
- src: "../vagrant/"

- src: "roles/"
dest: "provisioning/ansible/roles/"

- name: Setting permissions for project tree
file:
mode: 0777
path: "../{{ project }}"
state: directory
recurse: yes

- name: Add Vagrant host to inventory file
lineinfile:
dest: "../{{ project }}/inventory"
line: "\n[vagrant]\n{{ vm.network.private_network }} ansible_ssh_user={{ vm.ssh.username }} ansible_ssh_private_key_file=.vagrant/machines/default/virtualbox/private_key"

- name: Set name of the project to config.yml
lineinfile:
dest: "../{{ project }}/config.yml"
line: "project: {{ project }}\nsite_url: http://{{ project }}.dev"
insertafter: "^---$"
@@ -0,0 +1,4 @@
---
cibox_composer_drush:
version: 6.*
user: root
@@ -0,0 +1,16 @@
---
- name: Install Drush
shell: "composer global require drush/drush:{{ cibox_composer_drush.version }} --no-interaction --no-ansi"
sudo_user: "{{ cibox_composer_drush.user }}"

- name: Create symlinks
file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
force: yes
state: link
with_items:
- src: "/home/{{ cibox_composer_drush.user }}/.composer/vendor/drush/drush/drush"
dest: "/usr/local/bin/drush"
- src: "/home/{{ cibox_composer_drush.user }}/.composer/vendor/bin/drush.complete.sh"
dest: "/etc/bash_completion.d/drush"
@@ -1,21 +1,32 @@
---

composer_dir: /usr/share/composer
phpcs_bin: /usr/bin/phpcs

composer_global_require:
- drupal/coder:dev-7.x-2.x
- squizlabs/php_codesniffer=1.5.6

git_repos:
- { branch: 'master', repo: 'http://git.drupal.org/sandbox/coltrane/1921926.git', name: 'DrupalSecure' } # git clone --branch master http://git.drupal.org/sandbox/coltrane/1921926.git DrupalSecure
- { branch: '7.x-1.x', repo: 'https://github.com/klausi/drupalpractice.git', name: 'DrupalPractice' } #git clone --branch 7.x-1.x https://github.com/klausi/drupalpractice.git DrupalPractice
- { branch: 'master', repo: 'https://github.com/podarok/Symfony2-coding-standard.git', name: 'Symfony2' }
- branch: master
repo: http://git.drupal.org/sandbox/coltrane/1921926.git
name: DrupalSecure

- branch: 7.x-1.x
repo: https://github.com/klausi/drupalpractice.git
name: DrupalPractice

- branch: master
repo: https://github.com/podarok/phpcs-security-audit.git
name: Security

- branch: master
repo: https://github.com/podarok/Symfony2-coding-standard.git
name: Symfony2

phpcs_standards:
- { path: 'vendor/drupal/coder/coder_sniffer/Drupal', name: 'Drupal' } #/root/.composer/vendor/drupal/coder/coder_sniffer/Drupal Drupal
- { path: 'vendor/podarok/DrupalSecure/DrupalSecure', name: 'DrupalSecure' } #/root/.composer/vendor/podarok/DrupalSecure DrupalSecure
- { path: 'vendor/podarok/DrupalPractice/DrupalPractice', name: 'DrupalPractice' } #/root/.composer/vendor/podarok/DrupalPractice DrupalPractice
- { path: 'vendor/podarok/Symfony2', name: 'Symfony2' }
- vendor/drupal/coder/coder_sniffer/Drupal
- vendor/podarok/DrupalSecure/DrupalSecure
- vendor/podarok/Security/Security
- vendor/podarok/DrupalPractice/DrupalPractice

npm_packages:
- jshint
@@ -0,0 +1,68 @@
---
- name: Install APT repos
apt_repository:
repo: "{{ item }}"
with_items: sniffers_apt_repos

- name: Update APT cache
apt:
update_cache: yes
ignore_errors: yes

- name: Install APT packages
apt:
name: "{{ item }}"
state: present
with_items: sniffers_apt_packages

- name: Prepare directory for global Composer libs
file:
path: "{{ composer_dir }}"
state: directory

- name: Install Composer global requires
shell: "cd {{ composer_dir }} && composer require --prefer-dist {{ item }}"
with_items: composer_global_require

- name: Clone Git repos
git:
repo: "{{ item.repo }}"
dest: "{{ composer_dir }}/vendor/podarok/{{ item.name }}"
version: "{{ item.branch }}"
with_items: git_repos

- name: Install PHP CodeSniffer standards
file:
src: "{{ composer_dir }}/{{ item }}"
dest: "{{ composer_dir }}/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/{{ item | basename }}"
state: link
with_items: phpcs_standards

- name: Fix permissions for composer libs
file:
path: "{{ composer_dir }}"
mode: 0655
state: directory
recurse: yes

- name: Create symlink to phpcs binary
file:
src: "{{ composer_dir }}/vendor/bin/phpcs"
dest: /usr/bin/phpcs
mode: 0655
state: link
force: yes

- name: Install Node.js packages
npm:
name: "{{ item }}"
global: yes
with_items: npm_packages

- name: Update ruby alternatives for using ruby 1.9.1(3) version
shell: "update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby1.9.1.1.gz --slave /usr/bin/ri ri /usr/bin/ri1.9.1 --slave /usr/bin/irb irb /usr/bin/irb1.9.1 --slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1"

- name: Install Gem packages
shell: "gem install {{ item }}"
with_items: gem_packages
ignore_errors: yes
Oops, something went wrong.

0 comments on commit c18b024

Please sign in to comment.