Kouhei Sutou
null+****@clear*****
Tue Jul 18 12:22:06 JST 2017
Kouhei Sutou 2017-07-18 12:22:06 +0900 (Tue, 18 Jul 2017) New Revision: 94ecf1e660bb76ab648078b09d75704d4a066849 https://github.com/ranguba/chupa-text-vagrant/commit/94ecf1e660bb76ab648078b09d75704d4a066849 Message: Add Ansible configurations It's not tested yet. Added files: ansible/files/etc/logrotate.d/chupa-text ansible/files/etc/sudoers.d/no-password ansible/files/usr/lib/systemd/system/chupa-text.service ansible/playbook.yml Copied files: ansible/files/home/chupa-text/chupa-text-http-server/Gemfile.local (from Vagrantfile) Modified files: Vagrantfile Modified: Vagrantfile (+1 -1) =================================================================== --- Vagrantfile 2017-07-18 10:13:24 +0900 (1461a6d) +++ Vagrantfile 2017-07-18 12:22:06 +0900 (7a91fb3) @@ -32,7 +32,7 @@ Vagrant.configure("2") do |config| config.vm.provision "ansible" do |ansible| ansible.playbook = "ansible/playbook.yml" ansible.groups = { - "servers" => ["chupa-text.example.com"], + "servers" => ["chupa-text"], } ansible.host_key_checking = false # ansible.raw_arguments = [ Added: ansible/files/etc/logrotate.d/chupa-text (+14 -0) 100644 =================================================================== --- /dev/null +++ ansible/files/etc/logrotate.d/chupa-text 2017-07-18 12:22:06 +0900 (85d1039) @@ -0,0 +1,14 @@ +/var/log/chupa-text/*/* { + daily + missingok + rotate 365 + compress + delaycompress + notifempty + dateformat .%Y%m%d + dateyesterday + sharedscripts + postrotate + systemctl restart chupa-text + endscript +} Added: ansible/files/etc/sudoers.d/no-password (+1 -0) 100644 =================================================================== --- /dev/null +++ ansible/files/etc/sudoers.d/no-password 2017-07-18 12:22:06 +0900 (bbe23aa) @@ -0,0 +1 @@ +%sudo ALL=(ALL:ALL) NOPASSWD:ALL Copied: ansible/files/home/chupa-text/chupa-text-http-server/Gemfile.local (+5 -25) 53% =================================================================== --- Vagrantfile 2017-07-18 10:13:24 +0900 (1461a6d) +++ ansible/files/home/chupa-text/chupa-text-http-server/Gemfile.local 2017-07-18 12:22:06 +0900 (d435176) @@ -1,4 +1,4 @@ -# -*- mode: ruby -*- +# -*- ruby -*- # # Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # @@ -16,27 +16,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -Vagrant.configure("2") do |config| - config.vm.box = "bento/ubuntu-17.04" - config.vm.network "forwarded_port", guest: 20080, host: 20080 - log_directory = "/var/log/chupa-text" - if File.exist?(log_directory) - config.vm.synced_folder log_directory, "/var/log/chupa-text" - end - - config.vm.provider "virtualbox" do |virtualbox| - virtualbox.memory = "2048" - # virtualbox.memory = "4096" - end - - config.vm.provision "ansible" do |ansible| - ansible.playbook = "ansible/playbook.yml" - ansible.groups = { - "servers" => ["chupa-text.example.com"], - } - ansible.host_key_checking = false - # ansible.raw_arguments = [ - # "-vvv", - # ] - end -end +gem "chupa-text-decomposer-html" +gem "chupa-text-decomposer-webkit" +gem "chupa-text-decomposer-libreoffice" +gem "chupa-text-decomposer-pdf" Added: ansible/files/usr/lib/systemd/system/chupa-text.service (+14 -0) 100644 =================================================================== --- /dev/null +++ ansible/files/usr/lib/systemd/system/chupa-text.service 2017-07-18 12:22:06 +0900 (64cacb3) @@ -0,0 +1,14 @@ +[Unit] +Description=ChupaText - Text extraction service +After=network.target + +[Service] +Type=simple +User=chupa-text +Group=chupa-text +WorkingDirectory=/home/chupa-text/chupa-text-http-server +ExecStart=RAILS_ENV=production xvfb-run bin/rails server +Restart=always + +[Install] +WantedBy=multi-user.target Added: ansible/playbook.yml (+138 -0) 100644 =================================================================== --- /dev/null +++ ansible/playbook.yml 2017-07-18 12:22:06 +0900 (9d2f962) @@ -0,0 +1,138 @@ +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +- hosts: servers + become: yes + tasks: + - name: Set timezone + # Ansible 2.2 is required + # timezone: + # name: Asia/Tokyo + command: timedatectl set-timezone Asia/Tokyo + - name: Enable NTP + command: timedatectl set-ntp true + - name: Upgrade packages + apt: + update_cache: yes + cache_valid_time: 3600 + upgrade: safe + - name: Install packages + apt: + name: "{{ item }}" + with_items: + - apache2 + - apache2-dev + - curl + - g++ + - gcc + - git + - libapr1-dev + - libaprutil1-dev + - libcurl4-openssl-dev + - libreoffice + - libssl-dev + - make + - nodejs + - nodejs-legacy + - npm + - ruby + - ruby-dev + - sudo + - tzdata + - xvfb + - zlib1g-dev + - name: Install Bundler + gem: + name: bundler + user_install: no + - name: Install Yarn + npm: + name: yarn + global: yes + - name: Create chupa-text user + user: + name: chupa-text + groups: + - chupa-text + - sudo + append: true + - name: Enable no password sudo + copy: + src: etc/sudoers.d/no-password + dest: /etc/sudoers.d/no-password + - name: Clone ChupaText HTTP server + git: + repo: https://github.com/ranguba/chupa-text-http-server.git + dest: ~/chupa-text-http-server + depth: 1 + become_user: chupa-text + - name: Copy ChupaText HTTP server configurations + copy: + src: home/chupa-text/chupa-text-http-server/{{ item }} + dest: /home/chupa-text/chupa-text-http-server/{{ item }} + with_items: + - Gemfile.local + - name: Install dependencies + bundle: + chdir: ~/chupa-text-http-server + exclude_groups: + - development + - test + user_install: no + become_user: chupa-text + - name: Compile assets + shell: RAILS_ENV=production bin/rails assets:precompile + args: + chdir: ~/chupa-text-http-server + become_user: chupa-text + - name: Check secret key file + stat: + path: ~/chupa-text-http-server/config/secrets.yml + become_user: chupa-text + register: chupa_text_config_secrets + - name: Generate secret key + shell: | + (echo "production:"; \ + echo " secret_key_base: $(RAILS_ENV=production bin/rails secret)") > \ + config/secrets.yml + args: + chdir: ~/chupa-text-http-server + become_user: chupa-text + when: not chupa_text_config_secrets.exists + - name: Enable logrotate + copy: + src: etc/logrotate.d/{{ item }} + dest: /etc/logrotate.d/{{ item }} + with_items: + - chupa-text + - name: Enable systemd service + copy: + src: usr/lib/systemd/system/{{ item }} + dest: /usr/lib/systemd/system/{{ item }} + with_items: + - chupa-text.service + notify: + - Reload systemd + - Reload ChupaText HTTP server + + handlers: + - name: Reload systemd + command: systemctl daemon-reload + - name: Reload ChupaText HTTP server + service: + name: chupa-text + enabled: yes + state: restarted -------------- next part -------------- HTML����������������������������... 다운로드