master
1---
2- hosts: dev.controller5
3 vars:
4 host_ip: "{{ ansible_default_ipv4.address }}"
5 user_priv_key: "/home/centos/.ssh/id_rsa"
6 user_pub_key: "/home/centos/.ssh/id_rsa.pub"
7 tasks:
8 - name: Record public IP
9 shell: wget -qO- http://ipecho.net/plain ; echo
10 register: public_ip
11
12 - name: Install tools
13 yum: name={{item.name}} state={{item.state}} update_cache=yes
14 sudo: yes
15 with_items:
16 - {name: git, state: latest}
17 - {name: vim, state: latest}
18 - {name: nano, state: latest}
19 - {name: screen, state: latest}
20 - {name: "https://rdoproject.org/repos/rdo-release.rpm", state: present}
21 - {name: openstack-packstack, state: latest}
22
23 - name: Allow localhost root ssh connections (RDO requirement)
24 file: src=sshd_config dest=/etc/ssh/sshd_config owner=root
25 sudo: yes
26
27 - name: Researt SSH service
28 service: name=sshd state=restarted
29 sudo: yes
30
31 - name: ssh authorized key mgmt (1/4)
32 file: path={{item}} state=absent
33 with_items:
34 - "{{ user_priv_key }}"
35 - "{{ user_pub_key }}"
36
37 - name: ssh authorized key mgmt (2/4)
38 command: ssh-keygen -b 2048 -t rsa -f {{ user_priv_key }} -q -N ""
39
40 - name: ssh authorized key mgmt (3/4)
41 fetch: src={{ user_pub_key }} dest=controller.pub flat=yes
42
43 - name: ssh authorized key mgmt (4/4)
44 authorized_key:
45 user: root
46 key: "{{ lookup('file', 'controller.pub') }}"
47 path: '/root/.ssh/authorized_keys'
48 sudo: yes
49
50 - name: PackStack
51 command: packstack \
52 --allinone \
53 --install-hosts={{ host_ip }} \
54 --keystone-admin-passwd=supersecret \
55 --provision-demo=n
56 async: 1500
57 poll: 5
58 tags: this