summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2014-01-24 16:12:27 -0800
committerCosimo Cecchi <cosimoc@gnome.org>2014-01-24 16:12:27 -0800
commitb124b623944c574d2325589cd20198d2a79bb993 (patch)
tree8ab541848c8efe209e197b1bcab868e8118361c3
parent2ecb92e744b088e65ff41a8c8189fc4395e1565b (diff)
parentd5697c2531ae8f6e4ad8a462f0483aca47ae0665 (diff)
Merge pull request #493 from endlessm/issues/1620
First round of dev vm preparation scripts
-rw-r--r--tools/dev_env_setup/.gitignore4
-rw-r--r--tools/dev_env_setup/README.md41
-rw-r--r--tools/dev_env_setup/ansible.cfg140
-rw-r--r--tools/dev_env_setup/default_variables.yaml1
-rwxr-xr-xtools/dev_env_setup/install.sh72
-rw-r--r--tools/dev_env_setup/keys/id_rsa51
-rw-r--r--tools/dev_env_setup/keys/id_rsa.pub1
-rw-r--r--tools/dev_env_setup/playbooks/create_eos_app_shortcuts.yaml16
-rw-r--r--tools/dev_env_setup/playbooks/install_eos_dev_package.yaml9
-rw-r--r--tools/dev_env_setup/playbooks/setup_default_ssh_key.yaml17
-rw-r--r--tools/dev_env_setup/playbooks/setup_dev_folder.yaml12
-rw-r--r--tools/dev_env_setup/playbooks/setup_dev_machine.yaml27
-rw-r--r--tools/dev_env_setup/playbooks/setup_jhbuild.yaml50
-rw-r--r--tools/dev_env_setup/playbooks/setup_tools_root.yaml18
-rwxr-xr-xtools/dev_env_setup/setup_dev_machine.sh52
-rw-r--r--tools/dev_env_setup/templates/.jhbuildrc-auth.j24
-rw-r--r--tools/dev_env_setup/templates/add_dev_tools_folder.py45
-rw-r--r--tools/dev_env_setup/templates/known_hosts2
-rw-r--r--tools/dev_env_setup/templates/run_app_in_context_of.sh14
19 files changed, 576 insertions, 0 deletions
diff --git a/tools/dev_env_setup/.gitignore b/tools/dev_env_setup/.gitignore
new file mode 100644
index 0000000..cc324a5
--- /dev/null
+++ b/tools/dev_env_setup/.gitignore
@@ -0,0 +1,4 @@
+*.swp
+hosts
+*~
+*.log
diff --git a/tools/dev_env_setup/README.md b/tools/dev_env_setup/README.md
new file mode 100644
index 0000000..1207dca
--- /dev/null
+++ b/tools/dev_env_setup/README.md
@@ -0,0 +1,41 @@
+# Using Ansible
+
+## Principles
+
+- Ansible is an automatic configuration management (CM) tool that helps with deploying and
+configuring devices with little interaction and repeatability. Anything that one might manually
+"configure" on a target device should be done through Ansible to make sure that we can with
+minimal effort recreate critical parts of our infrastructure. While there are limitation to
+what can be done with this tool, the benefits (currently) far outweigh the cons.
+
+## Installation
+
+- To fully utilize these scripts, you need to manually install Ansible 1.2+ using `install.sh`
+since Ubuntu repositories only carry version 1.1. The install scripts downloads the proper
+dependencies, downloads Ansible, makes it, and installs it. The script also soft-links the
+configuration files from /etc to the ones in the repository. In general if you're using sudo,
+you don't need to do anything special to get the script to work. Ansible is fully configured
+on ansible@domain-services and the ansible test machine is on sg@10.0.1.8.
+
+## Running
+
+- Ansible uses configuration files (`ansible.cfg`), hosts definiton files (`hosts`), variable
+definitions (`default_variables.yaml`) and playbooks (any other `yaml`s) to run scripts.
+- To run a "playbook" yaml file, you need to type `ansible-playbook <playbook name>.yaml`. For
+standardization, top-level scripts are in this directory while helper modules have been included
+in the playbooks files.
+- root@obs-repository and ansible@domain-services pulic keys have been also placed in keys/ for
+reference
+- In general, the account that you are using to run the ansible script needs to have its ssh key
+in the target's ssh `authorized_hosts` file. You can do this by running `ssh-copy-id user@machine`
+- Logs are published on the server that the script is running on. This means that migrations are
+logged on ostree.endlessm.com and publishes logged on obs-repository.
+
+## Writing/extending the scripts
+
+- This is too broad of a topic so please refer to the current scripts and the following sites:
+ - https://gist.github.com/marktheunissen/2979474
+ - http://www.ansibleworks.com/docs/modules.html
+
+## Current scripts
+- setup_dev_env.sh - Installs the dev environment on the VM
diff --git a/tools/dev_env_setup/ansible.cfg b/tools/dev_env_setup/ansible.cfg
new file mode 100644
index 0000000..8e4b3a3
--- /dev/null
+++ b/tools/dev_env_setup/ansible.cfg
@@ -0,0 +1,140 @@
+# config file for ansible -- http://ansible.github.com
+# nearly all parameters can be overridden in ansible-playbook or with command line flags
+# ansible will read ~/.ansible.cfg or /etc/ansible/ansible.cfg, whichever it finds first
+
+[defaults]
+
+# location of inventory file, eliminates need to specify -i
+
+hostfile = /etc/ansible/hosts
+
+# location of ansible library, eliminates need to specify --module-path
+
+library = /usr/share/ansible
+
+# default module name used in /usr/bin/ansible when -m is not specified
+
+module_name = command
+
+# home directory where temp files are stored on remote systems. Should
+# almost always contain $HOME or be a directory writeable by all users
+
+remote_tmp = $HOME/.cache/ansible
+
+# Disable deprecation warnings
+deprecation_warnings=False
+
+# the default pattern for ansible-playbooks ("hosts:")
+
+pattern = *
+
+# the default number of forks (parallelism) to be used. Usually you
+# can crank this up.
+
+forks=5
+
+# the timeout used by various connection types. Usually this corresponds
+# to an SSH timeout
+
+timeout=10
+
+# when using --poll or "poll:" in an ansible playbook, and not specifying
+# an explicit poll interval, use this interval
+
+poll_interval=15
+
+# when specifying --sudo to /usr/bin/ansible or "sudo:" in a playbook,
+# and not specifying "--sudo-user" or "sudo_user" respectively, sudo
+# to this user account
+
+sudo_user=root
+
+# the following forces ansible to always ask for the sudo password (instead of having
+# to add -K to the commandline). Or you can use the environment variable (ANSIBLE_ASK_SUDO_PASS)
+
+#ask_sudo_pass=True
+
+# the following forces ansible to always ask for the ssh-password (-k)
+# can also be set by the environment variable ANSIBLE_ASK_PASS
+
+#ask_pass=True
+
+# connection to use when -c <connection_type> is not specified
+
+transport=paramiko
+
+# remote SSH port to be used when --port or "port:" or an equivalent inventory
+# variable is not specified.
+
+remote_port=22
+
+# if set, always run /usr/bin/ansible commands as this user, and assume this value
+# if "user:" is not set in a playbook. If not set, use the current Unix user
+# as the default
+
+#remote_user=root
+
+# the default sudo executable. If a sudo alternative with a sudo-compatible interface
+# is used, specify its executable name as the default
+
+sudo_exe=sudo
+
+# the default flags passed to sudo
+# sudo_flags=-H
+
+# how to handle hash defined in several places
+# hash can be merged, or replaced
+# if you use replace, and have multiple hashes named 'x', the last defined
+# will override the previously defined one
+# if you use merge here, hash will cumulate their keys, but keys will still
+# override each other
+# replace is the default value, and is how ansible always handled hash variables
+#
+# hash_behaviour=replace
+
+# if you need to use jinja2 extensions, you can list them here
+# use a coma to separate extensions, e.g. :
+# jinja2_extensions=jinja2.ext.do,jinja2.ext.i18n
+# no extensions are loaded by default
+
+#jinja2_extensions=
+
+# if set, always use this private key file for authentication, same as if passing
+# --private-key to ansible or ansible-playbook
+
+#private_key_file=/path/to/file
+
+# format of string $ansible_managed available within Jinja2 templates, replacing
+# {file}, {host} and {uid} with template filename, host and owner respectively.
+# The resulting string is passed through strftime(3) so it may contain any
+# time-formatting specifiers.
+#
+# Example: ansible_managed = DONT TOUCH {file}: call {uid} at {host} for changes
+ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
+
+# additional plugin paths for non-core plugins
+
+action_plugins = /usr/share/ansible_plugins/action_plugins
+callback_plugins = /usr/share/ansible_plugins/callback_plugins
+connection_plugins = /usr/share/ansible_plugins/connection_plugins
+lookup_plugins = /usr/share/ansible_plugins/lookup_plugins
+vars_plugins = /usr/share/ansible_plugins/vars_plugins
+filter_plugins = /usr/share/ansible_plugins/filter_plugins
+
+[paramiko_connection]
+
+# nothing to configure yet
+
+[ssh_connection]
+
+# if uncommented, sets the ansible ssh arguments to the following. Leaving off ControlPersist
+# will result in poor performance, so use transport=paramiko on older platforms rather than
+# removing it
+
+ssh_args=-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=/tmp/ansible-ssh-%h-%p-%r
+
+# the following makes ansible use scp if the connection type is ssh (default is sftp)
+
+scp_if_ssh=True
+
+
diff --git a/tools/dev_env_setup/default_variables.yaml b/tools/dev_env_setup/default_variables.yaml
new file mode 100644
index 0000000..ed97d53
--- /dev/null
+++ b/tools/dev_env_setup/default_variables.yaml
@@ -0,0 +1 @@
+---
diff --git a/tools/dev_env_setup/install.sh b/tools/dev_env_setup/install.sh
new file mode 100755
index 0000000..e56ff35
--- /dev/null
+++ b/tools/dev_env_setup/install.sh
@@ -0,0 +1,72 @@
+#!/bin/bash -e
+
+ANSIBLE_DIR="/etc/ansible"
+DEPENDENCIES="make python-pip python-dev git sshpass"
+
+if [[ $EUID -ne 0 ]]; then
+ echo "This script must be run as sudo or root. Exiting."
+ exit 1
+fi
+
+read -p "Are you sure you want to install the server config? " -n 1 -r
+echo # Move to a new line
+if [[ ! $REPLY =~ ^[Yy]$ ]]
+then
+ echo "Install canceled. Exiting."
+ exit 1
+fi
+
+echo "Checking dependencies"
+set +e
+ dpkg -s $DEPENDENCIES &> /dev/null
+ has_dependencies=$?
+set -e
+
+if [[ $has_dependencies -ne 0 || ! $(which ansible) ]]; then
+ echo "Installing $DEPENDENCIES"
+ apt-get update
+ apt-get install -y --force-yes $DEPENDENCIES
+ echo "Dependencies installed"
+
+ echo "Installing ansible"
+ pip install PyYAML jinja2 paramiko
+ rm -rf ${HOME}/apps/ansible
+ sudo -u $SUDO_USER -- mkdir -p ${HOME}/apps
+ pushd ${HOME}/apps
+ sudo -u $SUDO_USER -- git clone https://github.com/ansible/ansible.git
+ cd ansible
+ make install
+ popd
+ mkdir -p /etc/ansible
+fi
+
+if [[ ! $(which ansible-playbook) ]]; then
+ echo "Installing playbook script softlink"
+ sudo cp ${HOME}/apps/ansible/build/scripts-2.7/ansible-playbook /usr/bin/
+fi
+
+echo "Checking if this user has a ssh key"
+ssh_key="$HOME/.ssh/id_rsa"
+ssh_public_key="$ssh_key.pub"
+ssh_keygen_cmd="ssh-keygen -b 4096 -f $ssh_key"
+
+if [[ ! -f $ssh_public_key ]]; then
+ echo "No ssh key found. Regenerating"
+ echo "Using $ssh_keygen_cmd to create key"
+ sudo -u $SUDO_USER -- $ssh_keygen_cmd
+fi
+
+echo "Removing old files and links"
+rm -rf $ANSIBLE_DIR/hosts
+
+echo "Soft-linking relevant files"
+cwd=$(dirname $0)
+abs_cwd=$(readlink -f $cwd)
+
+echo "Current directory: $abs_cwd"
+ln -s $abs_cwd/hosts $ANSIBLE_DIR/hosts
+
+echo "Checking connectivity. If any failures appear below, it means that \
+ you need to push your ssh keys to those hosts with ssh-copy-id <user>@<machine>"
+
+sudo -u $SUDO_USER ansible all -m ping
diff --git a/tools/dev_env_setup/keys/id_rsa b/tools/dev_env_setup/keys/id_rsa
new file mode 100644
index 0000000..75a3eaf
--- /dev/null
+++ b/tools/dev_env_setup/keys/id_rsa
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKgIBAAKCAgEA3oftPUU6Mmr5AqDVjjAwGFv/jVt5y7Oo9vyE+CGtZ123U6/Y
+AGSXmuNZXrPcQYUau787pl4mEfQUKe3j+Gq1YYtlV9k/VTNA4bP+OBWSADl8rlkO
+dKxwyJOJiTdfDpisXFB6SXfrNOIvzi4PUGhwxxR+5jlP6no9t6Puu0OvH3DVPyeM
+8TnOXwZvxawSk8NxrLv7dH5ZKPqA6sHgpad0a3wvEDb8uLcJQwh8mNf+//lFBLXK
+tPNjM3/VrowdJb3W9qX/U+2AikR/BSuyk+ZJqeBU0zXHvWMHyqjgfBEoqvrF/jN9
+7aLTcR4yXter/EwaS6fGFGY498AbjkpqhUzbRXPrFw/LPvG+THtGQ9pD0n3lnD4Y
+r4XOASdkasmF+PAoxRnYKSXG01QoFiFMhUVrgXLejbWNBBVaECvylr1yeaqChpXf
+IdAqMrMGLPEyjtbIhxEVkDzXY8jgxtr7vaPqmnJmYxxDEcEOggZuqLKkfeqfjnBt
+Mn/phbQkTmY5zpRLM1x6QvT5jvumbinR5fDZK8v3k40tAM9ihyBT0S5N3CWV8wDR
+1xltG7VuB7Je7Z1VbNExGhGXz83lJ6gqZcIegH19TvAkZehc28HBoY/1MWSARqZO
+hOxwtcF0q4Jm765CCc3e5vwo1re5p2jqpJucKze5dt6khQFLed5H4V4P40UCAwEA
+AQKCA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dAkI
+FdzLL1JDpALecH9bHoqQuB4HM6+gD9JpuPGCw9KEGVhrOGK/Br7jBwAIxU2mYrEt
+SBnGZuzqDXXWoFmJxRJoXb9ljeDLITUJdWHyVrvgJZBeYHNZypVjyYNrVq17fPgy
+2OSKOlqbs7TSARoCGWTdi4cv6b5KK/stMHK0U769j1DaoO1jsa3WdtYsdDsyPqOZ
+40sChCh6vYiLIQUwe9QxeLD841LOQz2N2eftbKOpDPcgVTBr4E696qP+Ysb41/7P
+QGBRr/Tu6/7I8/Hxp1TBLSrxMtSFmHfU9YSXXFxeCCsB9KGokOI2DrQyDs7TIQ==
+-----END RSA PRIVATE KEY-----
diff --git a/tools/dev_env_setup/keys/id_rsa.pub b/tools/dev_env_setup/keys/id_rsa.pub
new file mode 100644
index 0000000..7c0aba6
--- /dev/null
+++ b/tools/dev_env_setup/keys/id_rsa.pub
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDeh+09RToyavkCoNWOMDAYW/+NW3nLs6j2/IT4Ia1nXbdTr9gAZJea41les9xBhRq7vzumXiYR9BQp7eP4arVhi2VX2T9VM0Dhs/44FZIAOXyuWQ50rHDIk4mJN18OmKxcUHpJd+s04i/OLg9QaHDHFH7mOU/qej23o+67Q68fcNU/J4zxOc5fBm/FrBKTw3Gsu/t0flko+oDqweClp3RrfC8QNvy4twlDCHyY1/7/+UUEtcq082Mzf9WujB0lvdb2pf9T7YCKRH8FK7KT5kmp4FTTNce9YwfKqOB8ESiq+sX+M33totNxHjJe16v8TBpLp8YUZjj3wBuOSmqFTNtFc+sXD8s+8b5Me0ZD2kPSfeWcPhivhc4BJ2RqyYX48CjFGdgpJcbTVCgWIUyFRWuBct6NtY0EFVoQK/KWvXJ5qoKGld8h0CoyswYs8TKO1siHERWQPNdjyODG2vu9o+qacmZjHEMRwQ6CBm6osqR96p+OcG0yf+mFtCROZjnOlEszXHpC9PmO+6ZuKdHl8Nkry/eTjS0Az2KHIFPRLk3cJZXzANHXGW0btW4Hsl7tnVVs0TEaEZfPzeUnqCplwh6AfX1O8CRl6FzbwcGhj/UxZIBGpk6E7HC1wXSrgmbvrkIJzd7m/CjWt7mnaOqkm5wrN7l23qSFAUt53kfhXg/jRQ== eos-dev-config@vm
diff --git a/tools/dev_env_setup/playbooks/create_eos_app_shortcuts.yaml b/tools/dev_env_setup/playbooks/create_eos_app_shortcuts.yaml
new file mode 100644
index 0000000..b641e74
--- /dev/null
+++ b/tools/dev_env_setup/playbooks/create_eos_app_shortcuts.yaml
@@ -0,0 +1,16 @@
+---
+# vim:ff=unix ts=2 sw=2 ai expandtab
+
+- name: "Setting default personality"
+ shell: eos-select-personality default
+
+- name: "Creating ~/.local/share/applications directory"
+ file: path=~/.local/share/applications state=directory
+ sudo: False
+
+- name: "Creating EOS links for various apps"
+ shell: cp /usr/share/applications/$item.desktop ~/.local/share/applications/eos-app-$item.desktop
+ with_items:
+ - gnome-terminal
+ - devhelp
+ sudo: False
diff --git a/tools/dev_env_setup/playbooks/install_eos_dev_package.yaml b/tools/dev_env_setup/playbooks/install_eos_dev_package.yaml
new file mode 100644
index 0000000..f69c31a
--- /dev/null
+++ b/tools/dev_env_setup/playbooks/install_eos_dev_package.yaml
@@ -0,0 +1,9 @@
+---
+# vim:ff=unix ts=2 sw=2 ai expandtab
+
+- name: "Ensuring that we can call apt from our scripts"
+ raw: "apt-get install -y --force-yes python-apt python"
+
+- name: "Ensuring that eos-dev is installed. If not, this operation will take a signifficant amount of time"
+ apt: name=eos-dev force=yes update_cache=true cache_valid_time=259200
+
diff --git a/tools/dev_env_setup/playbooks/setup_default_ssh_key.yaml b/tools/dev_env_setup/playbooks/setup_default_ssh_key.yaml
new file mode 100644
index 0000000..32e7cd8
--- /dev/null
+++ b/tools/dev_env_setup/playbooks/setup_default_ssh_key.yaml
@@ -0,0 +1,17 @@
+---
+# vim:ff=unix ts=2 sw=2 ai expandtab
+
+- name: "Creating ssh directory"
+ file: path=~/.ssh state=directory mode=700
+ sudo: False
+
+- name: "Copying default ssh keys"
+ copy: src=../keys/$item dest=~/.ssh/ mode=700
+ with_items:
+ - id_rsa
+ - id_rsa.pub
+ sudo: False
+
+- name: "Adding default known_hosts file"
+ copy: src=../templates/known_hosts dest=~/.ssh/
+ sudo: False
diff --git a/tools/dev_env_setup/playbooks/setup_dev_folder.yaml b/tools/dev_env_setup/playbooks/setup_dev_folder.yaml
new file mode 100644
index 0000000..562fd9b
--- /dev/null
+++ b/tools/dev_env_setup/playbooks/setup_dev_folder.yaml
@@ -0,0 +1,12 @@
+---
+# vim:ff=unix ts=2 sw=2 ai expandtab
+- name: "Copying files for desktop generation"
+ copy: src=../templates/$item dest=~/ mode=755
+ with_items:
+ - add_dev_tools_folder.py
+ - run_app_in_context_of.sh
+ sudo: False
+
+- name: "Creating development tools folder"
+ shell: executable=/bin/bash ~/run_app_in_context_of.sh eos-shell ~/add_dev_tools_folder.py &> ~/add_dev_tools_folder.log
+ sudo: False
diff --git a/tools/dev_env_setup/playbooks/setup_dev_machine.yaml b/tools/dev_env_setup/playbooks/setup_dev_machine.yaml
new file mode 100644
index 0000000..e87b827
--- /dev/null
+++ b/tools/dev_env_setup/playbooks/setup_dev_machine.yaml
@@ -0,0 +1,27 @@
+---
+# vim:ff=unix ts=2 sw=2 ai expandtab
+
+###
+# Notice the minus on the line below -- this starts the playbook's record
+# in the YAML document. Only one playbook is allowed per YAML file. Indent
+# the body of the playbook.
+-
+ hosts: dev_machine
+
+ sudo: True
+
+ vars_files:
+ - "../default_variables.yaml"
+
+ tasks:
+ - include: install_eos_dev_package.yaml
+
+ - include: setup_tools_root.yaml
+
+ - include: create_eos_app_shortcuts.yaml
+
+ - include: setup_dev_folder.yaml
+
+ - include: setup_default_ssh_key.yaml
+
+ - include: setup_jhbuild.yaml
diff --git a/tools/dev_env_setup/playbooks/setup_jhbuild.yaml b/tools/dev_env_setup/playbooks/setup_jhbuild.yaml
new file mode 100644
index 0000000..a8749a6
--- /dev/null
+++ b/tools/dev_env_setup/playbooks/setup_jhbuild.yaml
@@ -0,0 +1,50 @@
+---
+# vim:ff=unix ts=2 sw=2 ai expandtab
+
+- name: "Ensuring that git is installed"
+ apt: name=git update_cache=true cache_valid_time=259200
+
+- name: "Creating checkout directory"
+ file: path=~/checkout state=directory mode=755
+ sudo: False
+
+- name: "Cloning jhbuild"
+ git: repo=git://git.gnome.org/jhbuild
+ dest=~/checkout/jhbuild
+ sudo: False
+
+- name: "Installing jhbuild - autogen"
+ shell: cd ~/checkout/jhbuild && ./autogen.sh
+ sudo: False
+
+- name: "Installing jhbuild - make"
+ shell: cd ~/checkout/jhbuild && make
+ sudo: False
+
+- name: "Installing jhbuild - make install"
+ shell: cd ~/checkout/jhbuild && make install
+ sudo: False
+
+- name: "Creating glib schemas dir"
+ file: path=~/install/share/glib-2.0/schemas state=directory mode=755
+ sudo: False
+
+
+- name: "Creating /opt/gnome directory"
+ file: path=/opt/gnome state=directory mode=777
+
+- name: "Updating apt-file cache"
+ shell: apt-file update
+
+
+- name: "Installing jhbuild dependencies - this may take a very long time"
+ shell: executable=/bin/bash echo -e "y\n" | ~/.local/bin/jhbuild sysdeps --install
+ sudo: False
+
+- name: "Installing auth key"
+ template: src=../templates/.jhbuildrc-auth.j2 dest=~/.jhbuildrc-auth
+ sudo: False
+
+- name: "Cloning relevant modules - this will take a very long time - use htop and watch for git processes"
+ shell: executable=/bin/bash ~/.local/bin/jhbuild update endless-apps
+ sudo: False
diff --git a/tools/dev_env_setup/playbooks/setup_tools_root.yaml b/tools/dev_env_setup/playbooks/setup_tools_root.yaml
new file mode 100644
index 0000000..126a68b
--- /dev/null
+++ b/tools/dev_env_setup/playbooks/setup_tools_root.yaml
@@ -0,0 +1,18 @@
+---
+# vim:ff=unix ts=2 sw=2 ai expandtab
+
+- name: "Ensuring that git is installed"
+ apt: name=git update_cache=true cache_valid_time=259200
+
+- name: "Creating turbine directory"
+ file: path=~/checkout state=directory mode=755
+
+- name: "Cloning turbine"
+ git: repo=git://git.gnome.org/turbine
+ dest=~/checkout/turbine
+
+- name: "Installing turbine"
+ shell: cd ~/checkout/turbine && python setup.py install
+
+- name: "Installing transifex client"
+ shell: pip install transifex-client
diff --git a/tools/dev_env_setup/setup_dev_machine.sh b/tools/dev_env_setup/setup_dev_machine.sh
new file mode 100755
index 0000000..0033e50
--- /dev/null
+++ b/tools/dev_env_setup/setup_dev_machine.sh
@@ -0,0 +1,52 @@
+#!/bin/bash -e
+
+DEFAULT_USER="endless"
+DEFAULT_PASSWORD="endless"
+DEFAULT_IP="192.168.56.101"
+
+echo "To run this script, you need to have the following"
+echo " - VM running with the correct dev HD image"
+echo " - A user defined with sudo privileges"
+echo " - sshpass and latest Ansible installed on the local machine"
+echo
+read -p "Press [Enter] to continue..."
+
+if [[ ! $(which sshpass) ]]; then
+ echo "sshpass not found. Exiting"
+ echo "You can install it with sudo apt-get install sshpass"
+ exit 1
+fi
+
+read -e -p "Enter your machine's IP: " -i "$DEFAULT_IP" TARGET_IP
+read -e -p "Enter your machine's user: " -i "$DEFAULT_USER" TARGET_USER
+read -e -p "Enter your machine's password: " -i "${DEFAULT_PASSWORD}" TARGET_PASS
+
+API_KEY=""
+while [[ -z $API_KEY ]]; do
+ read -e -p "Enter your Github Personal Access Token (github.com/settings/applications): " -i "$API_KEY" API_KEY
+done
+
+echo
+
+echo -n "Checking connectivity to VM/machine..."
+sshpass -p "${TARGET_PASS}" ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $TARGET_USER@$TARGET_IP 'uname -a' &> /dev/null
+echo "[OK]"
+
+echo -n "Checking API key..."
+ git ls-remote -h https://$API_KEY@github.com/endlessm/eos-sdk &> /dev/null
+echo "[OK]"
+echo
+
+
+tmp_inventory=$(mktemp)
+trap "rm -f $tmp_inventory" EXIT
+
+echo "Creating Ansible inventory file in $tmp_inventory"
+cat << EOF > $tmp_inventory
+[dev_machine]
+dev_machine ansible_ssh_host=$TARGET_IP ansible_ssh_user="$TARGET_USER" ansible_sudo_pass="${TARGET_PASS}" ansible_ssh_pass="${TARGET_PASS}" ansible_connection=ssh
+EOF
+
+ansible-playbook -i $tmp_inventory playbooks/setup_dev_machine.yaml --extra-vars "api_key=$API_KEY"
+
+echo "Repos are cloned. You should be able to run 'jhbuild build' on the target"
diff --git a/tools/dev_env_setup/templates/.jhbuildrc-auth.j2 b/tools/dev_env_setup/templates/.jhbuildrc-auth.j2
new file mode 100644
index 0000000..67d2e1e
--- /dev/null
+++ b/tools/dev_env_setup/templates/.jhbuildrc-auth.j2
@@ -0,0 +1,4 @@
+# -*- mode: python -*-
+# -*- coding: utf-8 -*-
+
+repos['endlessm'] = 'https://{{ api_key }}@github.com/endlessm/'
diff --git a/tools/dev_env_setup/templates/add_dev_tools_folder.py b/tools/dev_env_setup/templates/add_dev_tools_folder.py
new file mode 100644
index 0000000..3e8df1b
--- /dev/null
+++ b/tools/dev_env_setup/templates/add_dev_tools_folder.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+import json
+import os
+import time
+from gi.repository import Gio, Gtk, GLib
+
+DIRECTORY_ID = 'eos-folder-user-99.directory'
+DIRECTORY_FILE_CONTENT="""[Desktop Entry]
+Name=Development
+Icon=eos-folder-tools-symbolic
+Type=Directory
+"""
+
+DEFAULT_LAYOUT_FILE='/usr/share/EndlessOS/personality-defaults/icon-grid-default.json'
+DESTINATIION_FOLDER= os.path.expanduser('~/.local/share/desktop-directories/') + DIRECTORY_ID
+
+def get_default_layout():
+ with open(DEFAULT_LAYOUT_FILE, 'r') as f:
+ return f.read()
+
+
+def write_folder_data():
+ with open(DESTINATIION_FOLDER, 'w') as f:
+ return f.write(DIRECTORY_FILE_CONTENT)
+
+def get_settings_string(layout):
+ settings = Gio.Settings.new("org.gnome.shell")
+
+
+ loaded_layout = json.loads(layout)
+ loaded_layout['desktop'].append(DIRECTORY_ID)
+ loaded_layout[DIRECTORY_ID] = [ 'eos-app-gnome-terminal.desktop' ,
+ 'eos-app-devhelp.desktop' ]
+
+ root=GLib.Variant('a{sas}', loaded_layout)
+ print "Setting the value"
+ settings.set_value("icon-grid-layout", root)
+ print "Syncing"
+ settings.sync()
+ print root
+
+if __name__ == "__main__":
+ layout = get_default_layout()
+ write_folder_data()
+ get_settings_string(layout)
diff --git a/tools/dev_env_setup/templates/known_hosts b/tools/dev_env_setup/templates/known_hosts
new file mode 100644
index 0000000..fdfd483
--- /dev/null
+++ b/tools/dev_env_setup/templates/known_hosts
@@ -0,0 +1,2 @@
+|1|KBJ34M/sigDkwEHXqWNtuZuTyIo=|dI52F1tauVq3UdnBDEWY9H76ZnI= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
+|1|ukqmPkGRPykqhLSygEMYacziZSA=|bghXjR7+Rr4YC3r15EbUJozp8No= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
diff --git a/tools/dev_env_setup/templates/run_app_in_context_of.sh b/tools/dev_env_setup/templates/run_app_in_context_of.sh
new file mode 100644
index 0000000..ae9facb
--- /dev/null
+++ b/tools/dev_env_setup/templates/run_app_in_context_of.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+PID="$(pgrep -o -f -u $(id -u) $1)"
+[ -z "$PID" ] && echo "No such process" > /dev/stderr && exit 1
+
+eval `strings /proc/$PID/environ | while read line; do
+ KEY="$(echo $line | sed -n 's/\([[:upper:]_]*\)=.*/\1/p')"
+ VALUE="$(echo $line | sed -n 's/[[:upper:]_]*=\([^"]*\)/\1/p')"
+ [ -z "$KEY" ] && continue;
+ [ -z "$VALUE" ] && continue;
+ echo "export $KEY='$VALUE'"
+done`
+
+echo "Now in same session as $PID. Running $2"
+$2