diff --git a/defaults/main.yaml b/defaults/main.yaml index b5c65c8..26ec316 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -3,6 +3,7 @@ nodepool_config_elements_dir: /etc/nodepool/elements nodepool_config_images_dir: /opt/nodepool/images nodepool_config_script_dir: /etc/nodepool/scripts +nodepool_config_zmq_publishers: [] # tasks/install.yaml nodepool_git_dest: /opt/git/openstack-infra/nodepool diff --git a/files/nodepool.service b/files/nodepool.service new file mode 100644 index 0000000..325b569 --- /dev/null +++ b/files/nodepool.service @@ -0,0 +1,12 @@ +[Unit] +Description=Nodepool Service + +[Service] +Type=simple +User=nodepool +Group=nodepool +EnvironmentFile=-/etc/sysconfig/nodepool +ExecStart=/usr/bin/nodepoold -d + +StandardOutput=syslog +StandardError=syslog diff --git a/files/nodepool.sudoers b/files/nodepool.sudoers new file mode 100644 index 0000000..32f4851 --- /dev/null +++ b/files/nodepool.sudoers @@ -0,0 +1,2 @@ +nodepool ALL=(ALL) NOPASSWD:ALL +Defaults:nodepool !requiretty diff --git a/files/nodepool.sysconfig b/files/nodepool.sysconfig new file mode 100644 index 0000000..a3520a4 --- /dev/null +++ b/files/nodepool.sysconfig @@ -0,0 +1 @@ +DIB_IMAGE_CACHE=/opt/nodepool/cache diff --git a/tasks/config.yaml b/tasks/config.yaml index 0c1f216..d1e5e03 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -1,5 +1,29 @@ --- +- name: Create system user account. + user: + createhome: yes + home: /var/lib/nodepool + name: nodepool + +- name: Create required directories. + file: + group: nodepool + owner: nodepool + path: "{{ item }}" + state: directory + with_items: + - /etc/nodepool + - "{{ nodepool_config_images_dir }}" + - /var/lib/nodepool + - /var/log/nodepool + - name: Template nodepool configuration file. template: dest: /etc/nodepool/nodepool.yaml src: nodepool.yaml.j2 + +- name: Copy sudoers file into place. + copy: + dest: /etc/sudoers.d/nodepool + src: nodepool.sudoers + validate: 'visudo -cf %s' diff --git a/tasks/install.yaml b/tasks/install.yaml index a2ecbd7..dd224c8 100644 --- a/tasks/install.yaml +++ b/tasks/install.yaml @@ -20,8 +20,3 @@ - include: install/pip.yaml when: nodepool_install_method == 'pip' - -- name: Create nodepool directory. - file: - path: /etc/nodepool - state: directory diff --git a/tasks/main.yaml b/tasks/main.yaml index 8ef1218..e5e03ab 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -2,6 +2,9 @@ - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yaml" +- name: Include nodepool configuration defaults. + include_vars: nodepool.yaml + - include: install.yaml - include: config.yaml diff --git a/tasks/service.yaml b/tasks/service.yaml index ed97d53..9d7b9f8 100644 --- a/tasks/service.yaml +++ b/tasks/service.yaml @@ -1 +1,16 @@ --- +- name: Copy systemd file into place. + copy: + dest: /etc/systemd/system + src: nodepool.service + +- name: Copy sysconfig file into place. + copy: + dest: /etc/sysconfig/nodepool + src: nodepool.sysconfig + +- name: Enable nodepool service. + service: + enabled: yes + name: nodepool + state: started diff --git a/templates/nodepool.yaml.j2 b/templates/nodepool.yaml.j2 index 85d564b..f1e53a8 100644 --- a/templates/nodepool.yaml.j2 +++ b/templates/nodepool.yaml.j2 @@ -2,4 +2,18 @@ elements-dir: {{ nodepool_config_elements_dir }} images-dir: {{nodepool_config_images_dir }} script-dir: {{ nodepool_config_script_dir }} +# TODO(pabelanger): Remove hardcoded variable. +dburi: sqlite:////var/lib/nodepool/nodepool.db + +{% set _zmq_publishers = { 'zmq-publishers': nodepool_config_zmq_publishers } -%} +{{ _zmq_publishers | to_nice_yaml }} +{% set _diskimages = { 'diskimages': diskimages } -%} +{{ _diskimages | to_nice_yaml }} +{% set _labels = { 'labels': labels } -%} +{{ _labels | to_nice_yaml }} +{% set _providers = { 'providers': providers } -%} +{{ _providers | to_nice_yaml }} +{% set _targets = { 'targets': targets } -%} +{{ _targets | to_nice_yaml }} + # {{ ansible_managed }} diff --git a/tests/files/nodepool.yaml b/tests/files/nodepool.yaml index eebe419..a996a9f 100644 --- a/tests/files/nodepool.yaml +++ b/tests/files/nodepool.yaml @@ -19,7 +19,6 @@ diskimages: elements: - centos - vm - release: trusty - name: ubuntu-trusty elements: - ubuntu diff --git a/vars/nodepool.yaml b/vars/nodepool.yaml new file mode 100644 index 0000000..21b18db --- /dev/null +++ b/vars/nodepool.yaml @@ -0,0 +1,5 @@ +--- +diskimages: [] +labels: [] +providers: [] +targets: []