summaryrefslogtreecommitdiff
path: root/vagrant.yaml
blob: 055a4a9dc62481df93a11066f87b238cc684b9f9 (plain)
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
---
###############################################################################
# This ansible playbook installs all supporting software necessary to run the
# ironic service locally into the vagrant VM attached. Its intent is to provide
# a quickstart development environment that doesn't pollute an engineer's own
# machine.
#
# The vagrant vm's IP address is assumed to be 192.168.99.11
#
# http://docs.openstack.org/developer/ironic/dev/dev-quickstart.html#exercising-the-services-locally
#
- hosts: ironic
  sudo: yes
  tasks:
    ############################################################################
    # APT Updates
    ############################################################################
    # Make sure our VM's software is ~@Latest
    - name: Apt Update
      apt: update_cache=yes
           upgrade=dist
           cache_valid_time=86400

    # Reboot if required.
    - name: Reboot system if required
      command: shutdown -r now 'Rebooting to complete system upgrade'
               removes=/var/run/reboot-required
      register: rebooted
    - name: Wait for VM Reboot.
      sudo: no
      local_action: wait_for
                    port=22
                    host="{{ip}}"
                    search_regex=OpenSSH
                    delay=10
                    timeout=900
      when: rebooted.changed

    ############################################################################
    # Install all the needed packages in one go.
    ############################################################################
    - name: Install Required Packages
      apt: name={{item}}
           state=present
      with_items:
      - rabbitmq-server
      - python-mysqldb
      - mysql-server
      - mysql-client

    ############################################################################
    # Configure rabbitmq.
    ############################################################################
    - name: Ensure rabbitmq is running
      service: name=rabbitmq-server
               state=started
               enabled=yes
    - name: Add ironic RabbitMQ user
      rabbitmq_user: user=ironic
                     password=ironic
                     vhost=/
                     configure_priv=.*
                     read_priv=.*
                     write_priv=.*
                     state=present

    ############################################################################
    # Configure mysql.
    ############################################################################
    - name: Configure MySQL
      lineinfile: dest=/etc/mysql/my.cnf
                  line="bind-address={{ip}}"
                  regexp="^bind\-address"
      notify: Restart MySQL
    - name: Create MySQL Database
      mysql_db: name=ironic state=present
    - name: Create ironic MySQL user
      mysql_user: name=ironic
                  password=ironic
                  host={{item}}
                  priv=ironic.*:ALL
                  state=present
      with_items:
      - localhost
      - "%"
    - name: Ensure mysql is running
      service: name=mysql
               state=started
               enabled=yes

    ############################################################################
    # Create ironic.conf.local configuration.
    ############################################################################
    - name: Update local configuration with vagrant parameters.
      sudo: no
      local_action: ini_file dest=etc/ironic/ironic.conf.local
                             section="{{item.section}}"
                             option="{{item.option}}"
                             value="{{item.value}}"
      with_items:
        - {
            section: 'glance',
            option: 'auth_strategy', value: 'noauth'
          }
        - {
            section: 'neutron',
            option: 'auth_strategy', value: 'noauth'
          }
        - {
            section: 'database',
            option: 'connection', value: "mysql+pymysql://ironic:ironic@{{ip}}/ironic"
          }
        - {
            section: 'DEFAULT',
            option: 'auth_strategy', value: 'noauth'
          }
        - {
            section: 'DEFAULT',
            option: 'enabled_drivers', value: 'pxe_ssh, agent_ssh, fake'
            # All other testing drivers require add'l packages
            # and should be enabled locally, if desired
          }
        - {
            section: 'DEFAULT',
            option: 'pecan_debug', value: 'true'
          }
        - {
            section: 'DEFAULT',
            option: 'verbose', value: 'true'
          }
        - {
            section: 'DEFAULT',
            option: 'debug', value: 'true'
          }
        - {
            section: 'oslo_messaging_rabbit',
            option: 'rabbit_host', value: "{{ip}}"
          }
        - {
            section: 'oslo_messaging_rabbit',
            option: 'rabbit_userid', value: "ironic"
          }
        - {
            section: 'oslo_messaging_rabbit',
            option: 'rabbit_password', value: "ironic"
          }
        - { # CORS Domain For Ironic-Webclient's dev server.
            section: 'cors',
            option: 'allowed_origin', value: "http://localhost:8000"
          }

  #############################################################################
  # Handlers
  #############################################################################
  handlers:
  - name: Restart MySQL
    service: name=mysql
             state=restarted
             enabled=yes