diff options
author | Adam Malinowski <a.malinowsk2@partner.samsung.com> | 2016-06-13 16:51:53 +0200 |
---|---|---|
committer | Adam Malinowski <a.malinowsk2@partner.samsung.com> | 2016-11-17 11:33:09 +0100 |
commit | d88d540710d8d5e8603edca1c78ff405bd19c9a1 (patch) | |
tree | 4d21ad4d5c0592379a417fbd2bffdb4a01595f0c | |
parent | 7199210e39c05d1131dd5c236a0a20d401a7028b (diff) | |
download | host-d88d540710d8d5e8603edca1c78ff405bd19c9a1.tar.gz host-d88d540710d8d5e8603edca1c78ff405bd19c9a1.tar.bz2 host-d88d540710d8d5e8603edca1c78ff405bd19c9a1.zip |
Add ansible configuration for master host
Change-Id: If0cbcb3a79689076fd00319935b03fa643bc08d3
-rw-r--r-- | config/hosts/README | 3 | ||||
-rwxr-xr-x | config/hosts/do_config.sh | 5 | ||||
-rw-r--r-- | config/hosts/hosts.sample | 1 | ||||
-rwxr-xr-x | config/hosts/master/do_master.sh | 2 | ||||
-rw-r--r-- | config/hosts/master/master.yml | 13 | ||||
-rw-r--r-- | config/hosts/master/roles/system/tasks/main.yml | 34 | ||||
-rw-r--r-- | config/hosts/master/roles/testlab/tasks/main.yml | 16 | ||||
-rw-r--r-- | config/hosts/master/roles/user/tasks/main.yml | 36 |
8 files changed, 110 insertions, 0 deletions
diff --git a/config/hosts/README b/config/hosts/README index a306ba2..e9d3bc5 100644 --- a/config/hosts/README +++ b/config/hosts/README @@ -25,3 +25,6 @@ Note that runner and master may be the same machine. Next step is to install ssh key in order to be able to run other scripts. To do that run script named 'installkey.sh'. It will execute ansible playbook 'installsshkey.yml' and you will have to enter password for specified user. + +Now you can run script 'do_config.sh' which will execute ansible with playbook +for 'master' machine. diff --git a/config/hosts/do_config.sh b/config/hosts/do_config.sh new file mode 100755 index 0000000..6d14ba6 --- /dev/null +++ b/config/hosts/do_config.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cd master +./do_master.sh + +cd .. diff --git a/config/hosts/hosts.sample b/config/hosts/hosts.sample index 9f71eec..a25eb17 100644 --- a/config/hosts/hosts.sample +++ b/config/hosts/hosts.sample @@ -14,3 +14,4 @@ [all:vars] ansible_user=vagrant +proxy=http://106.116.37.23:3128 diff --git a/config/hosts/master/do_master.sh b/config/hosts/master/do_master.sh new file mode 100755 index 0000000..efe77f2 --- /dev/null +++ b/config/hosts/master/do_master.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ansible-playbook master.yml --inventory-file=../hosts diff --git a/config/hosts/master/master.yml b/config/hosts/master/master.yml new file mode 100644 index 0000000..7d13d58 --- /dev/null +++ b/config/hosts/master/master.yml @@ -0,0 +1,13 @@ +--- +# This playbook configures master machine + +- hosts: master + become: yes + become_method: sudo + vars: + username: pita # Prerelease Image Testing Automation + + roles: + - user + - system + - testlab diff --git a/config/hosts/master/roles/system/tasks/main.yml b/config/hosts/master/roles/system/tasks/main.yml new file mode 100644 index 0000000..92cb500 --- /dev/null +++ b/config/hosts/master/roles/system/tasks/main.yml @@ -0,0 +1,34 @@ +--- +# This role configures system and installs + +- name: Update packages info + apt: + update_cache: yes + force: yes + +- name: Upgrade packages + apt: + upgrade: full + force: yes + +- name: Install tools + apt: "name={{ item }} state=present force=yes" + with_items: + - wget + - task-spooler + - python-bs4 + - git + +- name: Set http_proxy environment variable + lineinfile: + dest: /etc/environment + state: present + regexp: '^http_proxy' + line: 'http_proxy="{{ proxy }}"' + +- name: Set HTTP_PROXY environment variable + lineinfile: + dest: /etc/environment + state: present + regexp: '^HTTP_PROXY' + line: 'HTTP_PROXY="{{ proxy }}"' diff --git a/config/hosts/master/roles/testlab/tasks/main.yml b/config/hosts/master/roles/testlab/tasks/main.yml new file mode 100644 index 0000000..b1ce839 --- /dev/null +++ b/config/hosts/master/roles/testlab/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# This role does the job related to testlab-major + +- name: Prepare testlab-major directory + file: + path: /opt/testlab-major + state: directory + owner: "{{ username }}" + group: "{{ username }}" + +- name: Clone testlab-major repo + become: yes + become_user: "{{ username }}" + git: + repo: git://git.tizen.org/tools/testlab/major + dest: /opt/testlab-major diff --git a/config/hosts/master/roles/user/tasks/main.yml b/config/hosts/master/roles/user/tasks/main.yml new file mode 100644 index 0000000..705258e --- /dev/null +++ b/config/hosts/master/roles/user/tasks/main.yml @@ -0,0 +1,36 @@ +--- +# This playbook creates and sets up user + +- name: "Add group {{ username }}" + group: + name: "{{ username }}" + +# Add user +- name: "Add user {{ username }}" + user: + name: "{{ username }}" + groups: "{{ username }},sudo" + home: /home/{{ username }} + +- name: Remove ssh key from user + become: yes + become_user: "{{ username }}" + file: + path: "{{ item }}" + state: absent + with_items: + - "~/.ssh/id_rsa" + - "~/.ssh/id_rsa.pub" + +- name: Generate ssh key for user + become: yes + become_user: "{{ username }}" + command: "ssh-keygen -f ~/.ssh/id_rsa -N ''" + +- name: Fetch generated ssh key + become: yes + become_user: "{{ username }}" + fetch: + src: ~/.ssh/id_rsa.pub + dest: ~/tmp/id_rsa.pub + flat: yes |