From 4da8a25e264bb632e3230120e4c83828f814dc6a Mon Sep 17 00:00:00 2001 From: Thibaud Fabre Date: Wed, 21 Sep 2016 13:34:15 +0200 Subject: [PATCH] Fix Ansible roles to provision fully functional Vagrant VM --- .gitignore | 1 + Makefile | 2 - composer.json | 232 ++++++++--------- resources/ansible/roles/app/tasks/main.yml | 9 +- .../roles/app/templates/configuration.tpl | 244 ++++++++++++++++++ .../ansible/roles/mailcatcher/tasks/main.yml | 2 +- .../ansible/roles/mariadb/tasks/main.yml | 7 +- resources/ansible/vars/all.yml | 1 + 8 files changed, 374 insertions(+), 124 deletions(-) create mode 100644 resources/ansible/roles/app/templates/configuration.tpl diff --git a/.gitignore b/.gitignore index 7246930b58..73deff1565 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,4 @@ grammar/query.js grammar/jison-* pimple.json +playbook.retry diff --git a/Makefile b/Makefile index a1baa2ca5d..2c63f99c81 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ -# vim:noexpandtab:ts=4:sts=4:ft=make: - install: composer install -o rm -rf ./node_modules diff --git a/composer.json b/composer.json index a613ba34a7..41ff3a11cb 100644 --- a/composer.json +++ b/composer.json @@ -1,125 +1,121 @@ { - "name": "phraseanet/phraseanet", - "description": "Phraseanet", - "license": "GPL-3.0", - "config": { - "bin-dir": "bin/" + "name": "phraseanet/phraseanet", + "description": "Phraseanet", + "license": "GPL-3.0", + "config": { + "bin-dir": "bin/" + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/alchemy-fr/tcpdf-clone" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/alchemy-fr/tcpdf-clone" - }, - { - "type": "git", - "url": "https://github.com/romainneutron/ProcessManager.git" - }, - { - "type": "vcs", - "url": "https://github.com/alchemy-fr/imagine" - }, - { - "type": "vcs", - "url": "https://github.com/alchemy-fr/JMSTranslationBundle" - }, - { - "type": "vcs", - "url": "https://github.com/alchemy-fr/embed-bundle.git" - }, - { - "type": "git", - "url": "https://github.com/bburnichon/fractal.git" - } - ], - "require": { - "php": ">=5.5.9", - "ext-intl": "*", - "alchemy-fr/tcpdf-clone": "~6.0", - "alchemy/embed-bundle": "^0.4.1", - "alchemy/geonames-api-consumer": "~0.1.0", - "alchemy/google-plus-api-client": "~0.6.2", - "alchemy/mediavorus": "^0.4.4", - "alchemy/oauth2php": "1.0.0", - "alchemy/phlickr": "0.2.9", - "alchemy/phpexiftool": "^0.5.0", - "alchemy/rest-bundle": "^0.0.5", - "alchemy/symfony-cors": "^0.1.0", - "alchemy/task-manager": "2.0.x-dev@dev", - "alchemy/zippy": "^0.3.0", - "beberlei/assert": "^2.3", - "cocur/slugify": "^2.0", - "dailymotion/sdk": "~1.5", - "data-uri/data-uri": "~0.1.0", - "dflydev/doctrine-orm-service-provider": "~1.0", - "doctrine/cache": "1.6.x-dev", - "doctrine/dbal": "^2.4.0", - "doctrine/migrations": "^1.0.0", - "doctrine/orm": "^2.4.0", - "elasticsearch/elasticsearch": "~2.0", - "facebook/php-sdk": "~3.0", - "firebase/php-jwt": "^3.0.0", - "gedmo/doctrine-extensions": "~2.3.0", - "goodby/csv": "^1.3.0", - "guzzle/guzzle": "~3.0", - "hoa/compiler": "~2.0", - "hoa/console": "~2.0", - "hoa/dispatcher": "~0.0", - "hoa/router": "~2.0", - "igorw/get-in": "~1.0", - "imagine/imagine": "0.6.x-dev", - "ircmaxell/random-lib": "~1.0", - "jms/serializer": "~0.10", - "jms/translation-bundle": "dev-rebase-2015-10-20", - "justinrainbow/json-schema": "2.0.3 as 1.6.1", - "league/flysystem": "^1.0", - "league/flysystem-aws-s3-v2": "^1.0", - "league/fractal": "dev-bug/null-resource-serialization#891856f as 0.13.0", - "media-alchemyst/media-alchemyst": "^0.5", - "monolog/monolog": "~1.3", - "mrclay/minify": "~2.1.6", - "neutron/process-manager": "2.0.x-dev@dev", - "neutron/recaptcha": "~0.1.0", - "neutron/silex-filesystem-provider": "~1.0", - "neutron/silex-imagine-provider": "~0.1.0", - "neutron/temporary-filesystem": "~2.1", - "pagerfanta/pagerfanta": "^1.0", - "php-ffmpeg/php-ffmpeg": "~0.5.0", - "php-xpdf/php-xpdf": "~0.2.1", - "phpexiftool/exiftool": "10.07", - "ramsey/uuid": "^3.0", - "roave/security-advisories": "dev-master", - "silex/silex": "^1.3.0", - "silex/web-profiler": "~1.0", - "simple-bus/doctrine-orm-bridge": "^4.0", - "simple-bus/jms-serializer-bridge": "^1.0", - "simple-bus/message-bus": "^2.1", - "simple-bus/serialization": "^2.0", - "sorien/silex-dbal-profiler": "^1.1", - "sorien/silex-pimple-dumper": "^1.0", - "swiftmailer/swiftmailer": "~5.3.0", - "symfony/symfony": "~2.7.10|~2.8.3", - "themattharris/tmhoauth": "~0.7", - "twig/extensions": "^1.2.0", - "twig/twig": "~1.14, >=1.14.2", - "vierbergenlars/php-semver": "~2.1", - "webmozart/json": "^1.1", - "willdurand/negotiation": "^2.0.0-alpha1", - "zend/gdata": "~1.12.1" + { + "type": "git", + "url": "https://github.com/romainneutron/ProcessManager.git" }, - "require-dev": { - "mikey179/vfsStream": "~1.5", - "phpunit/phpunit": "^4.8|^5.0" + { + "type": "vcs", + "url": "https://github.com/alchemy-fr/imagine" }, - "autoload": { - "psr-0": { - "Alchemy\\": "lib", - "": "lib/classes" - } + { + "type": "vcs", + "url": "https://github.com/alchemy-fr/JMSTranslationBundle" }, - "include-path": ["vendor/zend/gdata/library"], - "extra": { - "branch-alias": { - "dev-master": "4.1.x-dev" - } + { + "type": "git", + "url": "https://github.com/bburnichon/fractal.git" } + ], + "require": { + "php": ">=5.5.9", + "ext-intl": "*", + "alchemy-fr/tcpdf-clone": "~6.0", + "alchemy/embed-bundle": "^0.4.1", + "alchemy/geonames-api-consumer": "~0.1.0", + "alchemy/google-plus-api-client": "~0.6.2", + "alchemy/mediavorus": "^0.4.4", + "alchemy/oauth2php": "1.0.0", + "alchemy/phlickr": "0.2.9", + "alchemy/phpexiftool": "^0.5.0", + "alchemy/rest-bundle": "^0.0.5", + "alchemy/symfony-cors": "^0.1.0", + "alchemy/task-manager": "2.0.x-dev@dev", + "alchemy/zippy": "^0.3.0", + "beberlei/assert": "^2.3", + "cocur/slugify": "^2.0", + "dailymotion/sdk": "~1.5", + "data-uri/data-uri": "~0.1.0", + "dflydev/doctrine-orm-service-provider": "~1.0", + "doctrine/cache": "1.6.x-dev", + "doctrine/dbal": "^2.4.0", + "doctrine/migrations": "^1.0.0", + "doctrine/orm": "^2.4.0", + "elasticsearch/elasticsearch": "~2.0", + "facebook/php-sdk": "~3.0", + "firebase/php-jwt": "^3.0.0", + "gedmo/doctrine-extensions": "~2.3.0", + "goodby/csv": "^1.3.0", + "guzzle/guzzle": "~3.0", + "hoa/compiler": "~2.0", + "hoa/console": "~2.0", + "hoa/dispatcher": "~0.0", + "hoa/router": "~2.0", + "igorw/get-in": "~1.0", + "imagine/imagine": "0.6.x-dev", + "ircmaxell/random-lib": "~1.0", + "jms/serializer": "~0.10", + "jms/translation-bundle": "dev-rebase-2015-10-20", + "justinrainbow/json-schema": "2.0.3 as 1.6.1", + "league/flysystem": "^1.0", + "league/flysystem-aws-s3-v2": "^1.0", + "league/fractal": "dev-bug/null-resource-serialization#891856f as 0.13.0", + "media-alchemyst/media-alchemyst": "^0.5", + "monolog/monolog": "~1.3", + "mrclay/minify": "~2.1.6", + "neutron/process-manager": "2.0.x-dev@dev", + "neutron/recaptcha": "~0.1.0", + "neutron/silex-filesystem-provider": "~1.0", + "neutron/silex-imagine-provider": "~0.1.0", + "neutron/temporary-filesystem": "~2.1", + "pagerfanta/pagerfanta": "^1.0", + "php-ffmpeg/php-ffmpeg": "~0.5.0", + "php-xpdf/php-xpdf": "~0.2.1", + "phpexiftool/exiftool": "10.07", + "ramsey/uuid": "^3.0", + "roave/security-advisories": "dev-master", + "silex/silex": "^1.3.0", + "silex/web-profiler": "~1.0", + "simple-bus/doctrine-orm-bridge": "^4.0", + "simple-bus/jms-serializer-bridge": "^1.0", + "simple-bus/message-bus": "^2.1", + "simple-bus/serialization": "^2.0", + "sorien/silex-dbal-profiler": "^1.1", + "sorien/silex-pimple-dumper": "^1.0", + "swiftmailer/swiftmailer": "~5.3.0", + "symfony/symfony": "~2.7.10|~2.8.3", + "themattharris/tmhoauth": "~0.7", + "twig/extensions": "^1.2.0", + "twig/twig": "~1.14, >=1.14.2", + "vierbergenlars/php-semver": "~2.1", + "webmozart/json": "^1.1", + "willdurand/negotiation": "^2.0.0-alpha1", + "zend/gdata": "~1.12.1" + }, + "require-dev": { + "mikey179/vfsStream": "~1.5", + "phpunit/phpunit": "^4.8|^5.0" + }, + "autoload": { + "psr-0": { + "Alchemy\\": "lib", + "": "lib/classes" + } + }, + "include-path": ["vendor/zend/gdata/library"], + "extra": { + "branch-alias": { + "dev-master": "4.1.x-dev" + } + } } diff --git a/resources/ansible/roles/app/tasks/main.yml b/resources/ansible/roles/app/tasks/main.yml index 2f42896117..632a820e81 100644 --- a/resources/ansible/roles/app/tasks/main.yml +++ b/resources/ansible/roles/app/tasks/main.yml @@ -1,6 +1,13 @@ --- -# application tasks to be customized and to run after the main provision +# Application tasks to be customized and to run after the main provision - name: Install global npm packages become: yes become_user: vagrant shell: export NVM_DIR="$HOME/.nvm" &&. "$NVM_DIR/nvm.sh" && npm install -g bower recess + +- name: Initialize application configuration + become: yes + become_user: vagrant + shell: 'bin/setup system:install --email=admin@{{ hostname }}.vb --password=admin --db-host=127.0.0.1 --db-port=3306 --db-user={{ mariadb.user }} --db-password={{ mariadb.password }} --db-template=fr --appbox={{ mariadb.database }} --databox={{ mariadb.databox_db }} --server-name=www.{{ hostname }}.vb --data-path=/vagrant/datas -y' + args: + chdir: /vagrant/ diff --git a/resources/ansible/roles/app/templates/configuration.tpl b/resources/ansible/roles/app/templates/configuration.tpl new file mode 100644 index 0000000000..346f11020b --- /dev/null +++ b/resources/ansible/roles/app/templates/configuration.tpl @@ -0,0 +1,244 @@ +servername: 'http://local.phrasea/' +languages: + available: [] + default: 'fr' +main: + maintenance: false + languages: [] + key: '' + api_require_ssl: true + database: + host: 127.0.0.1 + port: 3306 + user: '{{ mariadb.user }}' + password: '{{ mariadb.password }}' + dbname: '{{ mariadb.database }}' + driver: pdo_mysql + charset: UTF8 + database-test: + driver: pdo_sqlite + path: '/tmp/db.sqlite' + charset: UTF8 + cache: + type: MemcacheCache + options: + host: localhost + port: 11211 + search-engine: + type: phrasea + options: [] + task-manager: + status: started + enabled: true + options: + protocol: tcp + host: 127.0.0.1 + port: 6660 + linger: 500 + logger: + max-files: 10 + enabled: true + level: INFO + session: + type: 'file' + options: [] + ttl: 86400 + binaries: + ghostscript_binary: null + php_binary: null + swf_extract_binary: null + pdf2swf_binary: null + swf_render_binary: null + unoconv_binary: null + ffmpeg_binary: null + ffprobe_binary: null + mp4box_binary: null + pdftotext_binary: null + ffmpeg_timeout: 3600 + ffprobe_timeout: 60 + gs_timeout: 60 + mp4box_timeout: 60 + swftools_timeout: 60 + unoconv_timeout: 60 + task-manager: + status: started + listener: + protocol: tcp + host: 127.0.0.1 + port: 6700 + storage: + subdefs: null + cache: null + log : null + download: null + lazaret: null + caption: null + bridge: + youtube: + enabled: false + client_id: null + client_secret: null + developer_key: null + flickr: + enabled: false + client_id: null + client_secret: null + dailymotion: + enabled: false + client_id: null + client_secret: null +debugger: + allowed-ips: + - 192.168.56.1 +border-manager: + enabled: true + extension-mapping: { } + checkers: + - + type: Checker\Sha256 + enabled: true + - + type: Checker\UUID + enabled: true + - + type: Checker\Colorspace + enabled: false + options: + colorspaces: [cmyk, grayscale, rgb] + - + type: Checker\Dimension + enabled: false + options: + width: 80 + height: 160 + - + type: Checker\Extension + enabled: false + options: + extensions: [jpg, jpeg, bmp, tif, gif, png, pdf, doc, odt, mpg, mpeg, mov, avi, xls, flv, mp3, mp2] + - + type: Checker\Filename + enabled: false + options: + sensitive: true + - + type: Checker\MediaType + enabled: false + options: + mediatypes: [Audio, Document, Flash, Image, Video] +authentication: + auto-create: + templates: { } + captcha: + enabled: true + trials-before-display: 9 + providers: + facebook: + enabled: false + options: + app-id: '' + secret: '' + twitter: + enabled: false + options: + consumer-key: '' + consumer-secret: '' + google-plus: + enabled: false + options: + client-id: '' + client-secret: '' + github: + enabled: false + options: + client-id: '' + client-secret: '' + viadeo: + enabled: false + options: + client-id: '' + client-secret: '' + linkedin: + enabled: false + options: + client-id: '' + client-secret: '' +registration-fields: + - + name: company + required: true + - + name: lastname + required: true + - + name: firstname + required: true + - + name: geonameid + required: true +xsendfile: + enabled: false + type: nginx + mapping: [] +h264-pseudo-streaming: + enabled: false + type: nginx + mapping: [] +plugins: [] +api_cors: + enabled: false + allow_credentials: false + allow_origin: [] + allow_headers: [] + allow_methods: [] + expose_headers: [] + max_age: 0 + hosts: [] +session: + idle: 0 + lifetime: 604800 # 1 week +crossdomain: + site-control: 'master-only' + allow-access-from: + - + domain: '*.example.com' + secure: 'false' + - + domain: 'www.example.com' + secure: 'true' + to-ports: '507,516-523' + allow-access-from-identity: + - + fingerprint-algorithm: 'sha-1' + fingerprint: '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67' + - + fingerprint-algorithm: 'sha256' + fingerprint: '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67' + allow-http-request-headers-from: + - + domain: '*.bar.com' + secure: 'true' + headers: 'SOAPAction, X-Foo*' + - + domain: 'foo.example.com' + secure: 'false' + headers: 'Authorization,X-Foo*' +embed_bundle: + video: + player: videojs + autoplay: false + coverSubdef: previewx4 + available-speeds: + - 1 + - 1.5 + - 3 + audio: + player: videojs + autoplay: false + document: + player: flexpaper + enable-pdfjs: true +geocoding-providers: + - + name: 'mapBox' + public-key: '' diff --git a/resources/ansible/roles/mailcatcher/tasks/main.yml b/resources/ansible/roles/mailcatcher/tasks/main.yml index ddfdb1eb56..7d1ca213ea 100644 --- a/resources/ansible/roles/mailcatcher/tasks/main.yml +++ b/resources/ansible/roles/mailcatcher/tasks/main.yml @@ -11,7 +11,7 @@ # https://github.com/sj26/mailcatcher/issues/277#issuecomment-209154903 command: gem install mime-types --version "< 3" -- name: Install the mailcatcher (GEM) +- name: Install mailcatcher gem # gem module is flaky, this is consistent command: gem install mailcatcher --conservative ignore_errors: yes diff --git a/resources/ansible/roles/mariadb/tasks/main.yml b/resources/ansible/roles/mariadb/tasks/main.yml index d69ae8e10c..94cb1d88ff 100644 --- a/resources/ansible/roles/mariadb/tasks/main.yml +++ b/resources/ansible/roles/mariadb/tasks/main.yml @@ -39,11 +39,14 @@ - "{{ current_hostname.stdout | lower }}" - name: mariadb | Create databases - mysql_db: name={{ mariadb.database }} state=present login_user=root login_password={{ mariadb.root_password }} + mysql_db: name={{ item }} state=present login_user=root login_password={{ mariadb.root_password }} + with_items: + - "{{ mariadb.database }}" + - "{{ mariadb.databox_db }}" - name: mariadb | Import dump mysql_db: name={{ mariadb.database }} state=import login_user=root login_password={{ mariadb.root_password }} target=/vagrant/{{ mariadb.dump }} when: mariadb.dump - name: mariadb | Create users - mysql_user: name={{ mariadb.user }} password={{ mariadb.password }} priv={{ mariadb.database }}.*:ALL state=present login_user=root login_password={{ mariadb.root_password }} + mysql_user: name={{ mariadb.user }} password={{ mariadb.password }} priv=*.*:ALL state=present login_user=root login_password={{ mariadb.root_password }} diff --git a/resources/ansible/vars/all.yml b/resources/ansible/vars/all.yml index 6e82b2d711..0f2812a18a 100644 --- a/resources/ansible/vars/all.yml +++ b/resources/ansible/vars/all.yml @@ -37,6 +37,7 @@ mariadb: install: '1' root_password: toor database: ab_master + databox_db: db_master user: phraseanet password: phraseanet dump: ''