Add deploy files. Prepare first version 0.1
authorymh <ymh.work@gmail.com>
Wed, 12 Jun 2019 17:56:38 +0200
changeset 12 d9d75b93e132
parent 11 2c9f9128c49b
child 13 abe4451542dd
Add deploy files. Prepare first version
.hgignore
deploy/Pipfile
deploy/Pipfile.lock
deploy/README.md
deploy/Vagrantfile
deploy/deploy.sh
deploy/deploy.yml
deploy/group_vars/template.yml
deploy/host_vars/base.yml.tmpl
deploy/hosts/hosts.tmpl
--- a/.hgignore	Tue May 14 12:09:35 2019 +0200
+++ b/.hgignore	Wed Jun 12 17:56:38 2019 +0200
@@ -15,6 +15,11 @@
 # Dotenv
 .env
 
+# personal config
+.ruby-version
+Gemfile*
+.vscode
+
 # Vendor (e.g. Composer)
 src/vendor/*
 
@@ -51,3 +56,10 @@
 src/wp-signup.php
 src/wp-trackback.php
 src/xmlrpc.php
+
+# remove sensible info from deploy
+
+deploy/.vagrant
+deploy/host_vars/*
+deploy/group_vars/*
+deploy/hosts/*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/Pipfile	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,12 @@
+[[source]]
+url = "https://pypi.org/simple"
+verify_ssl = true
+name = "pypi"
+
+[packages]
+ansible = "*"
+
+[dev-packages]
+
+[requires]
+python_version = "3.7"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/Pipfile.lock	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,158 @@
+{
+    "_meta": {
+        "hash": {
+            "sha256": "074d6e8fe2c11255b4574daeea396b8537a465069173d4712e0d2d9818cdf144"
+        },
+        "pipfile-spec": 6,
+        "requires": {
+            "python_version": "3.7"
+        },
+        "sources": [
+            {
+                "name": "pypi",
+                "url": "https://pypi.org/simple",
+                "verify_ssl": true
+            }
+        ]
+    },
+    "default": {
+        "ansible": {
+            "hashes": [
+                "sha256:7234dd7d89150dc5bf035bc1ec3c084a8a0699d89e1c9b06b2af6dd34b2ef3ae"
+            ],
+            "index": "pypi",
+            "version": "==2.8.0"
+        },
+        "asn1crypto": {
+            "hashes": [
+                "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87",
+                "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49"
+            ],
+            "version": "==0.24.0"
+        },
+        "cffi": {
+            "hashes": [
+                "sha256:041c81822e9f84b1d9c401182e174996f0bae9991f33725d059b771744290774",
+                "sha256:046ef9a22f5d3eed06334d01b1e836977eeef500d9b78e9ef693f9380ad0b83d",
+                "sha256:066bc4c7895c91812eff46f4b1c285220947d4aa46fa0a2651ff85f2afae9c90",
+                "sha256:066c7ff148ae33040c01058662d6752fd73fbc8e64787229ea8498c7d7f4041b",
+                "sha256:2444d0c61f03dcd26dbf7600cf64354376ee579acad77aef459e34efcb438c63",
+                "sha256:300832850b8f7967e278870c5d51e3819b9aad8f0a2c8dbe39ab11f119237f45",
+                "sha256:34c77afe85b6b9e967bd8154e3855e847b70ca42043db6ad17f26899a3df1b25",
+                "sha256:46de5fa00f7ac09f020729148ff632819649b3e05a007d286242c4882f7b1dc3",
+                "sha256:4aa8ee7ba27c472d429b980c51e714a24f47ca296d53f4d7868075b175866f4b",
+                "sha256:4d0004eb4351e35ed950c14c11e734182591465a33e960a4ab5e8d4f04d72647",
+                "sha256:4e3d3f31a1e202b0f5a35ba3bc4eb41e2fc2b11c1eff38b362de710bcffb5016",
+                "sha256:50bec6d35e6b1aaeb17f7c4e2b9374ebf95a8975d57863546fa83e8d31bdb8c4",
+                "sha256:55cad9a6df1e2a1d62063f79d0881a414a906a6962bc160ac968cc03ed3efcfb",
+                "sha256:5662ad4e4e84f1eaa8efce5da695c5d2e229c563f9d5ce5b0113f71321bcf753",
+                "sha256:59b4dc008f98fc6ee2bb4fd7fc786a8d70000d058c2bbe2698275bc53a8d3fa7",
+                "sha256:73e1ffefe05e4ccd7bcea61af76f36077b914f92b76f95ccf00b0c1b9186f3f9",
+                "sha256:a1f0fd46eba2d71ce1589f7e50a9e2ffaeb739fb2c11e8192aa2b45d5f6cc41f",
+                "sha256:a2e85dc204556657661051ff4bab75a84e968669765c8a2cd425918699c3d0e8",
+                "sha256:a5457d47dfff24882a21492e5815f891c0ca35fefae8aa742c6c263dac16ef1f",
+                "sha256:a8dccd61d52a8dae4a825cdbb7735da530179fea472903eb871a5513b5abbfdc",
+                "sha256:ae61af521ed676cf16ae94f30fe202781a38d7178b6b4ab622e4eec8cefaff42",
+                "sha256:b012a5edb48288f77a63dba0840c92d0504aa215612da4541b7b42d849bc83a3",
+                "sha256:d2c5cfa536227f57f97c92ac30c8109688ace8fa4ac086d19d0af47d134e2909",
+                "sha256:d42b5796e20aacc9d15e66befb7a345454eef794fdb0737d1af593447c6c8f45",
+                "sha256:dee54f5d30d775f525894d67b1495625dd9322945e7fee00731952e0368ff42d",
+                "sha256:e070535507bd6aa07124258171be2ee8dfc19119c28ca94c9dfb7efd23564512",
+                "sha256:e1ff2748c84d97b065cc95429814cdba39bcbd77c9c85c89344b317dc0d9cbff",
+                "sha256:ed851c75d1e0e043cbf5ca9a8e1b13c4c90f3fbd863dacb01c0808e2b5204201"
+            ],
+            "version": "==1.12.3"
+        },
+        "cryptography": {
+            "hashes": [
+                "sha256:24b61e5fcb506424d3ec4e18bca995833839bf13c59fc43e530e488f28d46b8c",
+                "sha256:25dd1581a183e9e7a806fe0543f485103232f940fcfc301db65e630512cce643",
+                "sha256:3452bba7c21c69f2df772762be0066c7ed5dc65df494a1d53a58b683a83e1216",
+                "sha256:41a0be220dd1ed9e998f5891948306eb8c812b512dc398e5a01846d855050799",
+                "sha256:5751d8a11b956fbfa314f6553d186b94aa70fdb03d8a4d4f1c82dcacf0cbe28a",
+                "sha256:5f61c7d749048fa6e3322258b4263463bfccefecb0dd731b6561cb617a1d9bb9",
+                "sha256:72e24c521fa2106f19623a3851e9f89ddfdeb9ac63871c7643790f872a305dfc",
+                "sha256:7b97ae6ef5cba2e3bb14256625423413d5ce8d1abb91d4f29b6d1a081da765f8",
+                "sha256:961e886d8a3590fd2c723cf07be14e2a91cf53c25f02435c04d39e90780e3b53",
+                "sha256:96d8473848e984184b6728e2c9d391482008646276c3ff084a1bd89e15ff53a1",
+                "sha256:ae536da50c7ad1e002c3eee101871d93abdc90d9c5f651818450a0d3af718609",
+                "sha256:b0db0cecf396033abb4a93c95d1602f268b3a68bb0a9cc06a7cff587bb9a7292",
+                "sha256:cfee9164954c186b191b91d4193989ca994703b2fff406f71cf454a2d3c7327e",
+                "sha256:e6347742ac8f35ded4a46ff835c60e68c22a536a8ae5c4422966d06946b6d4c6",
+                "sha256:f27d93f0139a3c056172ebb5d4f9056e770fdf0206c2f422ff2ebbad142e09ed",
+                "sha256:f57b76e46a58b63d1c6375017f4564a28f19a5ca912691fd2e4261b3414b618d"
+            ],
+            "version": "==2.7"
+        },
+        "jinja2": {
+            "hashes": [
+                "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013",
+                "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b"
+            ],
+            "version": "==2.10.1"
+        },
+        "markupsafe": {
+            "hashes": [
+                "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
+                "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
+                "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
+                "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
+                "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
+                "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
+                "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
+                "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
+                "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
+                "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
+                "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
+                "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
+                "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
+                "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
+                "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
+                "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
+                "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
+                "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
+                "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
+                "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
+                "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
+                "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
+                "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
+                "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
+                "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
+                "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
+                "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
+                "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"
+            ],
+            "version": "==1.1.1"
+        },
+        "pycparser": {
+            "hashes": [
+                "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3"
+            ],
+            "version": "==2.19"
+        },
+        "pyyaml": {
+            "hashes": [
+                "sha256:1adecc22f88d38052fb787d959f003811ca858b799590a5eaa70e63dca50308c",
+                "sha256:436bc774ecf7c103814098159fbb84c2715d25980175292c648f2da143909f95",
+                "sha256:460a5a4248763f6f37ea225d19d5c205677d8d525f6a83357ca622ed541830c2",
+                "sha256:5a22a9c84653debfbf198d02fe592c176ea548cccce47553f35f466e15cf2fd4",
+                "sha256:7a5d3f26b89d688db27822343dfa25c599627bc92093e788956372285c6298ad",
+                "sha256:9372b04a02080752d9e6f990179a4ab840227c6e2ce15b95e1278456664cf2ba",
+                "sha256:a5dcbebee834eaddf3fa7366316b880ff4062e4bcc9787b78c7fbb4a26ff2dd1",
+                "sha256:aee5bab92a176e7cd034e57f46e9df9a9862a71f8f37cad167c6fc74c65f5b4e",
+                "sha256:c51f642898c0bacd335fc119da60baae0824f2cde95b0330b56c0553439f0673",
+                "sha256:c68ea4d3ba1705da1e0d85da6684ac657912679a649e8868bd850d2c299cce13",
+                "sha256:e23d0cc5299223dcc37885dae624f382297717e459ea24053709675a976a3e19"
+            ],
+            "version": "==5.1"
+        },
+        "six": {
+            "hashes": [
+                "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
+                "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
+            ],
+            "version": "==1.12.0"
+        }
+    },
+    "develop": {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/README.md	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,16 @@
+# Recherchecontributive deployment
+
+The deployment is done with ansible.
+A pipfile is available to set it up.
+This deployment take 
+
+## Start the deploy
+
+- `deploy.sh <profile> <hg tag>`. Example: `deploy.sh test tip`
+
+## configuration file:
+
+- `hosts/hosts.<profile>`
+- `group_vars/<profile>.yml`
+- `host_vars/<hostname>/base.yml` base `host_vars/base.yml.tmpl`
+`
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/Vagrantfile	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,70 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# All Vagrant configuration is done below. The "2" in Vagrant.configure
+# configures the configuration version (we support older styles for
+# backwards compatibility). Please don't change it unless you know what
+# you're doing.
+Vagrant.configure("2") do |config|
+  # The most common configuration options are documented and commented below.
+  # For a complete reference, please see the online documentation at
+  # https://docs.vagrantup.com.
+
+  # Every Vagrant development environment requires a box. You can search for
+  # boxes at https://vagrantcloud.com/search.
+  config.vm.box = "generic/debian10"
+
+  # Disable automatic box update checking. If you disable this, then
+  # boxes will only be checked for updates when the user runs
+  # `vagrant box outdated`. This is not recommended.
+  # config.vm.box_check_update = false
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  # NOTE: This will enable public access to the opened port
+  # config.vm.network "forwarded_port", guest: 80, host: 8080
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine and only allow access
+  # via 127.0.0.1 to disable public access
+  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  config.vm.network "private_network", ip: "172.16.1.5"
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network "public_network"
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  # config.vm.synced_folder "../data", "/vagrant_data"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  # config.vm.provider "virtualbox" do |vb|
+  #   # Display the VirtualBox GUI when booting the machine
+  #   vb.gui = true
+  #
+  #   # Customize the amount of memory on the VM:
+  #   vb.memory = "1024"
+  # end
+  #
+  # View the documentation for the provider you are using for more
+  # information on available options.
+
+  # Enable provisioning with a shell script. Additional provisioners such as
+  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
+  # documentation for more information about their specific syntax and use.
+  config.vm.provision "shell", inline: <<-SHELL
+    apt-get update
+    apt-get install -y unzip php php-curl php-zip
+  SHELL
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/deploy.sh	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+SCRIPTNAME=`basename "$0"`
+
+usage() {
+  echo -n "${SCRIPTNAME} [CONFIG] [VERSION]
+
+Deploy the <config> using ansible.
+config must be in the following list : test, prod
+"
+}
+
+if [[ "$#" -ne 2 ]]; then
+    usage
+    exit 1
+fi
+
+config=${1}
+VERSION=${2}
+
+case $config in
+    test) configOK=true;;
+    prod) configOK=true;;
+    *)    configOK=false;;
+esac
+
+if [[ "$configOK" = false ]]; then
+    usage
+    exit 1
+fi
+
+pushd "$SCRIPTPATH"
+
+ANSIBLE_SSH_PIPELINING=1 ANSIBLE_STDOUT_CALLBACK=debug ansible-playbook -v -i "./hosts/hosts.$config" -l "$config" ./deploy.yml --extra-vars "rc_version=${VERSION}" --ask-vault-pass
+
+popd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/deploy.yml	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,72 @@
+- hosts: localhost
+  connection: local
+  vars:
+    build_dir: "{{playbook_dir}}/build/tmp/rc/"
+  tasks:
+
+    - name: mkdir build folder
+      file:
+        path: "{{playbook_dir}}/build/tmp"
+        state: directory
+
+    - name: clear checkout dir if exists
+      file:
+        path: "{{build_dir}}"
+        state: absent
+
+    - name: checkout 
+      hg:
+        repo: "{{rc_repo}}"
+        version: "{{rc_version}}"
+        force: yes
+        dest: "{{build_dir}}"
+
+- hosts: remote
+  vars:
+    src_dir: "{{playbook_dir}}/build/tmp/rc/src/"
+  tasks:
+
+    - name: create the destination directory
+      file:
+        path: "{{remote_path}}"
+        state: directory
+        owner: "{{ansible_user_id}}"
+      become: yes
+
+    - name: sync the sources
+      synchronize:
+        src: "{{src_dir}}"
+        dest: "{{remote_path}}"
+
+    - name: clean previous version of composer
+      file:
+        path: /tmp/composer/composer
+        state: absent
+
+    - name: create the destination directory
+      file:
+        path: /tmp/composer
+        state: directory
+
+    - name: download new version of composer
+      get_url:
+        url: https://getcomposer.org/composer.phar
+        dest: /tmp/composer/composer
+        mode: 0755
+
+    - name: clean composer
+      file:
+        path: "{{remote_path}}/vendor"
+        state: absent
+
+    - name: call composer
+      composer:
+        command: install
+        working_dir: "{{remote_path}}"
+      environment:
+        PATH: /tmp/composer:/usr/bin
+
+    - name: create env file if needed
+      template:
+        src: env.j2
+        dest: "{{remote_path}}/.env"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/group_vars/template.yml	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,12 @@
+---
+# irinotes repository url
+rc_repo: "https://www.iri.centrepompidou.fr/dev/hg/recherchecontributive.org"
+
+# irinites version, should be overriden from command line
+rc_version: "HEAD"
+
+# remote path for static files
+# note : must not end with /
+remote_path: "/var/www/recherchecontributive.org"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/host_vars/base.yml.tmpl	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,17 @@
+---
+rc_db_name: wordpressdb
+rc_db_user: wordpress
+rc_db_password: wordpress
+rc_db_host: db:3306
+rc_wp_home: http://recherchecontributive.test:8080
+rc_wp_siteurl: ${WP_HOME}/wp
+rc_wp_env: development
+
+rc_auth_key:
+rc_secure_auth_key:
+rc_logged_in_key:
+rc_nonce_key:
+rc_auth_salt:
+rc_secure_auth_salt:
+rc_logged_in_salt:
+rc_nonce_salt:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/hosts/hosts.tmpl	Wed Jun 12 17:56:38 2019 +0200
@@ -0,0 +1,9 @@
+
+[test]
+localhost
+
+[test:children]
+remote
+
+[remote]
+172.16.1.5 ansible_user=vagrant ansible_ssh_private_key_file=<path_to_/deploy/.vagrant/machines/default/virtualbox/private_key>