-
Notifications
You must be signed in to change notification settings - Fork 1
/
devstack-setup.yml
180 lines (170 loc) · 5.63 KB
/
devstack-setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
---
# This first play sets up the environment in
# RDOCloud for running devstack on a nova instance
# there.
- hosts: localhost
connection: local
vars:
ansible_python_interpreter: "/usr/bin/env python3"
vars_files:
- keys.yml
tasks:
- name: add ssh ingress rule
os_security_group_rule:
state: present
security_group: default
protocol: tcp
port_range_min: 22
port_range_max: 22
- name: add http ingress rule
os_security_group_rule:
state: present
security_group: default
protocol: tcp
port_range_min: 80
port_range_max: 80
- name: create keypair
os_keypair:
state: present
name: "{{ key_name }}"
public_key_file: "{{ public_key_file }}"
- name: create a volume to hold development files
os_volume:
state: present
wait: yes
size: 200
display_name: development_files
- name: create private network for the host VM
os_network:
state: present
name: host-VM-private-net
- name: create private subnet on that network
os_subnet:
state: present
network_name: host-VM-private-net
name: host-VM-private-subnet
cidr: 192.168.0.0/24
gateway_ip: 192.168.0.1
- name: create router for the private network
os_router:
state: present
name: host-VM-private-router
interfaces: host-VM-private-subnet
network: 38.145.32.0/22
- name: launch the host VM
os_server:
name: devstack_host_vm
state: present
wait: yes
auto_ip: yes
image: 'CentOS-7-x86_64-GenericCloud-1708'
flavor: m1.large
key_name: "{{ key_name }}"
network: host-VM-private-net
volumes:
- development_files
userdata: |
#cloud-config
runcmd:
- sed -i -e 's/#\?\(PasswordAuthentication\s*\).*$/\1 no/' /etc/ssh/sshd_config
- sed -i -e 's/#\?\(GSSAPIAuthentication\s*\).*$/\1 no/' /etc/ssh/sshd_config
- sed -i -e 's/#\?\(GSSAPICleanupCredentials\s*\).*$/\1 no/' /etc/ssh/sshd_config
- printf "\nKexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256\nCiphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr\nMACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com\n" >> /etc/ssh/sshd_config
- service sshd restart
register: devstack_host_vm
- debug:
msg: "Devstack host vm booted with public IP {{ devstack_host_vm.openstack.public_v4 }}"
- name: add the devstack host_vm to our ansible inventory
add_host: hostname="{{ devstack_host_vm.openstack.public_v4 }}"
groups=clouddev
ansible_ssh_private_key_file="{{ private_key_file }}"
ansible_ssh_user=centos
- name: Remove the conflicting entry from the ~/.ssh/known_hosts
when: devstack_host_vm.openstack.public_v4 is defined
lineinfile:
path: ~/.ssh/known_hosts
state: absent
regexp: "{{ devstack_host_vm.openstack.public_v4 }} *"
- name: Create local login script
template: src=login.sh
dest=.
mode=0755
# Wait for the server to finish booting and become accessible.
- hosts: clouddev
gather_facts: no
tasks:
- name: Wait for instance to finish booting
connection: local
wait_for:
host="{{ ansible_ssh_host|default(inventory_hostname) }}"
search_regex=OpenSSH
port=22
delay=30
timeout=600
- name: Try to login to the instance
raw: "/bin/ls"
retries: 5
delay: 10
ignore_errors: true
# Configure the /opt filesystem. This has to be separate from the
# previous step and next step for ordering.
- hosts: clouddev
gather_facts: no
vars:
ansible_python_interpreter: /usr/bin/python2.7
# Create a filesystem on the attached volume. /dev/vdb
# This is where we'll keep development files
tasks:
- name: Create /opt filesystem
filesystem: fstype=ext4 dev=/dev/vdb
become: true
become_user: root
become_method: sudo
- name: Mount /opt filesystem
mount: name=/opt src=/dev/vdb fstype=ext4 state=mounted
become: true
become_user: root
become_method: sudo
# Configure the remote machine for convenience
- hosts: clouddev
tasks:
- name: Color the prompt string green
become: true
lineinfile:
path: /etc/bashrc
line: 'PS1="\[\033[1;32m\][\u@\h \W]\$\[\033[0m\] "'
insertbefore: EOF
- name: Install vim
become: true
yum:
name: vim
state: latest
# wget's very useful when cloud image is required
- name: Install wget
become: true
yum:
name: wget
state: latest
- name: Set background color for vim as dark
become: true
lineinfile:
path: /etc/vimrc
line: 'set background=dark'
insertbefore: EOF
# Configure the host VM. This needs to come last.
- hosts: clouddev
vars:
ansible_python_interpreter: /usr/bin/python2.7
# Use a separate filesystem for the local repository cache.
openstack_dev_repos_dir: "/opt/devel/repos"
openstack_project_dir: "/opt/devel/projects"
openstack_repos_dir: "/opt/devel/repos"
python_dev_install_pypy: false
python_dev_versions:
- version: "3.5"
- version: "2.7"
swap:
blocks_count: 4048
roles:
- fixdns
- devstack