Skip to content

Commit

Permalink
Merge pull request #1 from hostdime/deployment_updates
Browse files Browse the repository at this point in the history
Deployment updates
  • Loading branch information
jb4free authored Dec 23, 2016
2 parents ab32fe8 + a189ed7 commit c3361af
Show file tree
Hide file tree
Showing 30 changed files with 236 additions and 219 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Ansible
external_roles/*
*.retry

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
104 changes: 87 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,100 @@
# autodeploy
Deployment automation efforts for PF9 pre-reqs, host agent, and authorization.

Deployment automation efforts for Platform9's prerequisites, host agent(s), and authorization via the use of Ansible.


## Requirements

* Ansible 2
* Python 2
* shade


## Instructions

After cloning the repo you'll need to create the following files.
Clone the repository.
```
$ git clone https://github.com/platform9/autodeploy.git
$ cd autodeploy/
```

After cloning the repository, it is required to configure the variables for deployment.
```
# cp -a group_vars/all_example.yml group_vars/all.yml
# vim group_vars/all.yml
```

The SSH connection details for the hypervisor (Nova) and/or image (Glance) nodes should be defined in a new inventory file.
```
# vim production
```

Finally, the Playbook can be run.
```
# ansible-playbook -i production site.yml
```


### Variables

Hypervisor required variables:

### group_vars/all.yml
* group_vars/all.yml
* os_region = OpenStack region.
* os_username = OpenStack admin username.
* os_password: OpenStack password.
* os_tenant: OpenStack admin project.
* du_url = The unique URL provided by Platform9 to access the controller resources.

ssh_user: root
os_region: <OS region>
os_username: <username>
os_password: <password>
os_tenant: <tenant name>
du_url: <DU_UR>
Image node required variable:

### inventory/hypervisors
* group_vars/all.yml
* pf9_id

[hypervisors]
<fqdn> ansible_host=<ip>
Optional variables:

## Example Playbook
* group_vars/all.yml
* manage_hostname = Boolean value. Set the hostname equal to the Ansible inventory_hostname for the host.
* manage_resolvers = Boolean value. Append servers listed in the "dns_resolvers" variable to the resolvers file.
* dns_resolvers = The DNS resolvers to use for the remote node.


### Inventory

All of the hypervisor nodes should be listed in the inventory file. They should be under the "hypervisors" group. Each node should be named after their fully qualified domain name (FQDN) that will be used as the hostname. Here are a few examples for creating Ansible inventory connection details based on common scenarios.

* SSH directly in as root.
```
<FQDN> ansible_host=<IP> ansible_port=<SSH_PORT> ansible_user=root
```

* SSH in as a privileged user and run Ansible tasks using "sudo."
```
<FQDN> ansible_host=<IP> ansible_port=<SSH_PORT> ansible_become=True ansible_user=<SSH_USER> ansible_become_method=sudo
```

* SSH in as a privileged user and then switch to the root user with "su" to run Ansible tasks.
```
<FQDN> ansible_host=<IP> ansible_port=<SSH_PORT> ansible_become=True ansible_user=<SSH_USER> ansible_become_method=su ansible_user=<SSH_USER>
```

* Hypervisor and image storage group inventory example:
```
# vim production
compute01.domain.tld ansible_host=10.0.0.11 ansible_port=2222 ansibler_user=root
compute02.domain.tld ansible_host=10.0.0.12 ansible_become=True ansible_user=bob ansible_become_method=sudo
compute03.domain.tld ansible_host=10.0.0.13 ansible_port=2222 ansible_become=True ansible_user=joe ansible_become_method=su
image01.domain.tld ansible_host=10.0.0.71
image02.domain.tld ansible_host=10.0.0.72
[hypervisors]
compute[01:03].domain.tld
[image_storage]
image[01:02].domain.tld
```

- hosts: hypervisors
roles:
- neutron-prerequisites
- pf9-hostagent

## License

Commerical
2 changes: 2 additions & 0 deletions group_vars/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all.yml
all.yaml
14 changes: 0 additions & 14 deletions group_vars/all.yml

This file was deleted.

14 changes: 14 additions & 0 deletions group_vars/all_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# Set hostname equal to inventory_hostname
manage_hostname: False
# Append DNS resolvers to /etc/resolv.conf
manage_resolvers: False
dns_resolvers:
- 8.8.8.8
- 8.8.4.4
# these variables are required to be filled in for the end-user's environment
os_username:
os_password:
os_region:
os_tenant:
du_url:
2 changes: 1 addition & 1 deletion inventory/pf9.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_du_inventory(self):
@os_token: str
@rtype: dict
"""
# Check if OS Token exits
# Check if OS Token exists
if self.pf9_keystone_file and os.path.isfile(self.pf9_keystone_file):
try:
os_token_file = open(self.pf9_keystone_file)
Expand Down
40 changes: 40 additions & 0 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
- name: Check for hardware virtualization support
# svm - AMD SVM
# vmx - Intel VT-x
command: "grep -Eiq '(svm|vmx)' /proc/cpuinfo"
ignore_errors: True
changed_when: hw_virt.rc != 0
register: hw_virt
when: inventory_hostname in groups.hypervisors

- name: Quitting if hardware virtualization is not enabled
fail:
msg: "Hardware virtualization is not present, or not enabled."
when: hw_virt|failed and
inventory_hostname in groups.hypervisors

- name: Set system hostname
hostname:
name: "{{ inventory_hostname }}"
register: hostname_result

- name: Update /etc/hosts to reflect hostname change
lineinfile:
state: present
dest: /etc/hosts
regexp: "^(127.0.0.1).*$"
line: "127.0.0.1\t{{ inventory_hostname_short }}\t{{ inventory_hostname }}\tlocalhost"
register: etc_hosts_result

- name: Set DNS resolvers
lineinfile:
state: present
dest: /etc/resolv.conf
create: yes
line: "nameserver {{ item }}"
with_items: "{{ dns_resolvers }}"
when: manage_resolvers == True

- include: redhat.yml
when: ansible_os_family == "RedHat"
20 changes: 20 additions & 0 deletions roles/common/tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: Install libselinux-python
yum:
state: present
name: libselinux-python

- name: Modify devpts mount point
mount:
state: present
name: /dev/pts
src: devpts
fstype: devpts
opts: gid=5,mode=620
dump: 0
passno: 0
register: devpts_result

- name: Remount devpts mount point
command: mount -o remount devpts
when: devpts_result|changed
2 changes: 0 additions & 2 deletions roles/glance-host/defaults/main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion roles/glance-host/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
uri:
url: "{{ du_url }}/resmgr/v1/hosts/{{ pf9_id }}/roles/pf9-glance-role"
headers:
X-Auth-Token: "{{ hostvars['localhost']['os_auth_token'] }}"
X-Auth-Token: "{{ hostvars[inventory_hostname]['os_auth_token'] }}"
register: glance_role_custom

- name: Set glance_datadir path
Expand Down
5 changes: 5 additions & 0 deletions roles/neutron-prerequisites/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ neutron_sysctl:
net.ipv4.conf.default.rp_filter: 0
net.ipv4.ip_forward: 1
net.ipv4.tcp_mtu_probing: 1
neutron_kernel_modules:
- 8021q
- bonding
- bridge
- br_netfilter
34 changes: 16 additions & 18 deletions roles/neutron-prerequisites/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
---
- name: Set DNS resolvers if unset
lineinfile:
state: present
dest: /etc/resolv.conf
create: yes
line: "nameserver {{ item }}"
with_items: "{{ default_resolvers }}"
when: ansible_dns.nameservers is undefined

- name: Install libselinux-python
yum:
state: present
name: libselinux-python
when: ansible_distribution == "CentOS"

- name: Load kernel modules required for Neutron
include: modules.yml

Expand All @@ -25,10 +10,23 @@
sysctl_set: yes
with_dict: "{{ neutron_sysctl }}"

- include: centos.yml
when: ansible_distribution == 'CentOS'
- include: redhat.yml
when: ansible_os_family == "RedHat"

- include: ubuntu.yml
when: ansible_distribution == 'Ubuntu'

- include: networking.yml
- name: Create required OVS bridges
openvswitch_bridge:
bridge: "{{ item }}"
state: present
with_items:
- br-ext
- br-vlan

- name: Set br-ext external bridge ID
openvswitch_bridge:
bridge: br-ext
state: present
external_ids:
bridge-id: br-ext
11 changes: 3 additions & 8 deletions roles/neutron-prerequisites/tasks/modules.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
---
- include_vars: "{{ item }}"
with_first_found:
- "vars/{{ ansible_distribution }}.yml"
- vars/default.yml

- modprobe:
state: present
name: "{{ item }}"
with_items: "{{ neutron_modules }}"
with_items: "{{ neutron_kernel_modules }}"

- name: Persist modules on boot
lineinfile:
state: present
line: "{{ item }}"
dest: /etc/modules
with_items: "{{ neutron_modules }}"
with_items: "{{ neutron_kernel_modules }}"
when: ansible_os_family == "Debian"

- name: Persist modules on boot
Expand All @@ -23,5 +18,5 @@
dest: /etc/modules-load.d/neutron.conf
create: yes
line: "{{ item }}"
with_items: "{{ neutron_modules }}"
with_items: "{{ neutron_kernel_modules }}"
when: ansible_os_family == "RedHat"
15 changes: 0 additions & 15 deletions roles/neutron-prerequisites/tasks/networking.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
policy: targeted
state: permissive

- name: Disable firewall
- name: Disable firewalld
service:
state: stopped
name: firewalld
enabled: no
ignore_errors: True

- name: Installing iptables-services
yum:
name: iptables-services
state: present

- name: Assemble list of ifcfg scripts
find:
path: /etc/sysconfig/network-scripts
Expand All @@ -35,7 +40,7 @@
enabled: no
ignore_errors: True

- name: Add PF9 yum repo
- name: Add Platform9 Yum repository
yum:
name: https://s3-us-west-1.amazonaws.com/platform9-neutron/noarch/platform9-neutron-repo-1-0.noarch.rpm
state: present
Expand All @@ -48,7 +53,7 @@
disablerepo: '*'
enablerepo: 'platform9-neutron-el7-repo'

- name: Enable & Start Open vSwitch
- name: Enable and start Open vSwitch
service:
name: openvswitch
state: started
Expand Down
4 changes: 2 additions & 2 deletions roles/neutron-prerequisites/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- ifenslave
- vlan

- name: Add PF9 repo
- name: Add Platform9 APT repository
apt_repository:
repo: 'deb http://platform9-neutron.s3-website-us-west-1.amazonaws.com ubuntu/'
state: present
Expand All @@ -18,7 +18,7 @@
state: present
force: yes

- name: Enable & Start Open vSwitch
- name: Enable and start Open vSwitch
service:
name: openvswitch-switch
state: started
Expand Down
Loading

0 comments on commit c3361af

Please sign in to comment.