Skip to content

Commit

Permalink
Merge pull request openebs#144 from ksatchit/master
Browse files Browse the repository at this point in the history
PR#104 Improvements to Ansible based CI framework
  • Loading branch information
kmova authored Jun 28, 2017
2 parents 992bc25 + bc50ca9 commit b53a3c6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
5 changes: 3 additions & 2 deletions e2e/ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ ansible
├── files
├── inventory
│ └── group_vars
| └── host_vars
├── playbooks
dedicated
│ └ hyperconverged
└── dedicated
│ └── hyperconverged
├── plugins
│ └── callback
└── roles
Expand Down
25 changes: 25 additions & 0 deletions e2e/ansible/inventory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A brief description of the files in this directory is given below :
file
- hosts : Default inventory file referred to in the playbooks
- group_vars/all.yml : Contains global variables for ansible playbooks
- host_vars/localhost.yml : Contains localhost attributes such as sudo password which are needed for privilege escalation

The machines.in needs to be updated with the details of the hosts used in the openebs setup prior to execution of the ansible
playbooks. Provided below are some instructions to consider while doing this
Expand All @@ -31,3 +32,27 @@ playbooks. Provided below are some instructions to consider while doing this

- Lines can be commented (such as these) by inserting '#' symbol before the host code

The contents of a typical ansible inventory 'hosts' file is as shown below :

```
localhost ansible_connection=local ansible_become_pass="{{ lookup('env','LOCAL_USER_PASSWORD') }}"
[openebs-mayamasters]
mayamaster01 ansible_ssh_host=20.10.49.11
[openebs-mayamasters:vars]
ansible_ssh_user="{{ lookup('env','MACHINES_USER_NAME') }}"
ansible_ssh_pass="{{ lookup('env','MACHINES_USER_PASSWORD') }}"
ansible_become_pass="{{ lookup('env','MACHINES_USER_PASSWORD') }}"
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
[openebs-mayahosts]
mayahost01 ansible_ssh_host=20.10.49.12
mayahost02 ansible_ssh_host=20.10.49.13
[openebs-mayahosts:vars]
ansible_ssh_user="{{ lookup('env','USER_NAME') }}"
ansible_ssh_pass="{{ lookup('env','USER_PASSWORD') }}"
ansible_become_pass="{{ lookup('env','USER_PASSWORD') }}"
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
```
3 changes: 3 additions & 0 deletions e2e/ansible/inventory/host_vars/localhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
ansible_connection: local
ansible_become_pass: "{{ lookup('env','LOCAL_USER_PASSWORD') }}"
8 changes: 2 additions & 6 deletions e2e/ansible/roles/inventory/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
---
- name: Source the env
shell : source ~/.profile
- name: Generate Inventory
shell: source ~/.profile; python {{role_path}}/files/generate-inventory.py {{inventory_input_path}}/machines.in
args:
executable: /bin/bash
delegate_to: 127.0.0.1

- name: Generate Inventory
command: "python {{role_path}}/files/generate-inventory.py {{inventory_input_path}}/machines.in"
delegate_to: 127.0.0.1

- name: Sync Inventory
meta: refresh_inventory

3 changes: 2 additions & 1 deletion e2e/ansible/roles/k8s-localhost/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
name: "{{ item }}"
state: present
with_items: "{{ pip_local_packages }}"
delegate_to: 127.0.0.1
delegate_to: 127.0.0.1
become: true

## Common preparation tasks

Expand Down
2 changes: 1 addition & 1 deletion e2e/ansible/roles/prerequisites/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
state: present
with_items: "{{ pip_pre_packages }}"
delegate_to: 127.0.0.1

become: true

0 comments on commit b53a3c6

Please sign in to comment.