Skip to content

Commit

Permalink
Moved CentOS 6 and 7 images into contrib - closes #39
Browse files Browse the repository at this point in the history
- Changed version format of Centos 6/7 images
- Added Zabbix agent to the Centos 7 image
- Updated GitLab CE image to 9.0.5
  • Loading branch information
dn0 committed Apr 14, 2017
1 parent be30352 commit ca55996
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 141 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
BUILD_TARGETS = base-centos-6 \
base-centos-7 \
base-64-es \
centos-6 \
centos-7 \
esdc-mon \
esdc-mgmt \
esdc-cfgdb \
esdc-dns \
esdc-img \
esdc-node \
contrib-centos-6 \
contrib-centos-7 \
contrib-gitlab-ce \
contrib-centos7-desktop

Expand Down Expand Up @@ -44,7 +44,7 @@ define HELP_TEXT
clean delete all appliance VMs and their base images in reverse order
clean-<app> delete appliance VM and its base image
all build all appliances/images
base build all base appliances (base-centos-6 base-centos-7 base-64-es centos-6 centos-7)
base build all base appliances (base-centos-6 base-centos-7 base-64-es)
esdc build all Danube Cloud appliances (esdc-mon, esdc-mgmt, esdc-cfgdb, esdc-dns, esdc-img, esdc-node)
<app> build an appliance/image, one of:

Expand All @@ -68,7 +68,7 @@ endef
.PHONY: help init check clean imgapi-tree all $(BUILD_TARGETS) $(clean_targets)

help:
@echo -e "$(subst $(newline),\n,${HELP_TEXT})"
@printf "$(subst $(newline),\n,${HELP_TEXT})"

init:
@bin/ansible.sh init
Expand Down Expand Up @@ -97,7 +97,7 @@ $(BUILD_TARGETS):

all: $(BUILD_TARGETS)

base: base-centos-6 base-centos-7 base-64-es centos-6 centos-7
base: base-centos-6 base-centos-7 base-64-es

esdc: esdc-mon esdc-mgmt esdc-cfgdb esdc-dns esdc-img esdc-node

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
- name: Create virtual machine
hosts: buildnode
vars_files:
- vars/build/vm/centos-6.yml
- vars/build/vm/contrib-centos-6.yml
pre_tasks:
- include: tasks/build/cleanup.yml
- include: tasks/build/prepare-base-image.yml
roles:
- smartos-vm
tasks:
- include: tasks/build/centos/register-host.yml
hostname=centos-6
hostname=contrib-centos-6

- name: Install and configure appliance
hosts: centos-6
hosts: contrib-centos-6
gather_facts: true
vars_files:
- vars/build/os/contrib-centos-6.yml
roles:
- iptables
- cloud-init
Expand All @@ -30,6 +32,6 @@
- name: Create and save image
hosts: buildnode
vars_files:
- vars/build/vm/centos-6.yml
- vars/build/vm/contrib-centos-6.yml
tasks:
- include: tasks/build/centos/create-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
- name: Create virtual machine
hosts: buildnode
vars_files:
- vars/build/vm/centos-7.yml
- vars/build/vm/contrib-centos-7.yml
pre_tasks:
- include: tasks/build/cleanup.yml
- include: tasks/build/prepare-base-image.yml
roles:
- smartos-vm
tasks:
- include: tasks/build/centos/register-host.yml
hostname=centos-7
hostname=contrib-centos-7

- name: Install and configure appliance
hosts: centos-7
hosts: contrib-centos-7
gather_facts: true
vars_files:
- vars/build/os/contrib-centos-7.yml
# Change hostname back to localhost.localdomain
pre_tasks:
- name: Configure hostname
Expand All @@ -30,11 +32,13 @@
- mdata-client
- rc-scripts
- qemu-guest-agent
- zabbix-agent
- contrib-centos-7
- vm-image

- name: Create and save image
hosts: buildnode
vars_files:
- vars/build/vm/centos-7.yml
- vars/build/vm/contrib-centos-7.yml
tasks:
- include: tasks/build/centos/create-image.yml
37 changes: 37 additions & 0 deletions ansible/roles/contrib-centos-7/files/zabbix-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
SCRIPT="${0}"

log() {
logger -t "${SCRIPT}" "$@"
}

log "Starting post-deploy configuration of Zabbix agent"

ZABBIX_AGENT_CONFIG="/etc/zabbix/zabbix_agentd.conf"
ZABBIX_SETUP_DONE="$(mdata-get org.erigones:zabbix_setup_done 2>/dev/null || echo '')"
log "Metadata key org.erigones:zabbix_setup_done value=${ZABBIX_SETUP_DONE}"

if [[ -z "${ZABBIX_SETUP_DONE}" ]]; then
ZABBIX_IP="$(mdata-get org.erigones:zabbix_ip 2>/dev/null || echo '')"
log "Metadata key org.erigones:zabbix_ip value=${ZABBIX_IP}"

if [[ -n ${ZABBIX_IP} ]]; then
sed -i "s/^Server=.*/Server=${ZABBIX_IP}/" "${ZABBIX_AGENT_CONFIG}"
sed -i "s/^ServerActive=.*/ServerActive=${ZABBIX_IP}/" "${ZABBIX_AGENT_CONFIG}"
log "Restarting zabbix-agent"
systemctl enable zabbix-agent
systemctl restart zabbix-agent
else
log "Disabling zabbix-agent"
systemctl stop zabbix-agent
systemctl disable zabbix-agent
fi

log "Setting metadata org.erigones:zabbix_setup_done value=true"
mdata-put org.erigones:zabbix_setup_done true
fi

log "Finished post-deploy configuration of Zabbix agent"
exit 0
12 changes: 12 additions & 0 deletions ansible/roles/contrib-centos-7/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- fail: msg="Invalid OS; Only CentOS 7 is supported."
when: ansible_distribution != "CentOS" or ansible_distribution_major_version != "7"

- name: Install additional packages
yum: name="{{ item }}" state=present
with_items:
- man-pages
- vim-enhanced
- screen

- name: Install /var/lib/rc-scripts/21-zabbix-agent.sh
copy: src=zabbix-agent.sh dest=/var/lib/rc-scripts/21-zabbix-agent.sh mode=0750 owner=root group=root
2 changes: 2 additions & 0 deletions ansible/vars/build/os/contrib-centos-6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
firewall_allowed_tcp_ports:
- port: 22
9 changes: 9 additions & 0 deletions ansible/vars/build/os/contrib-centos-7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rc_scripts_after:
- zabbix-agent.service

firewall_allowed_tcp_ports:
- port: 22
- port: 10050

selinux_permissive_domains:
- zabbix_agent_t
6 changes: 3 additions & 3 deletions ansible/vars/build/os/contrib-gitlab-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ firewall_allowed_tcp_ports:
- port: 22
- port: 80
- port: 443
- port: 10051
- port: 10050

selinux_permissive_domains:
- zabbix_agent_t

gitlab_ce_version: "8.16.6"
gitlab_ce_checksum: "90feeca7a6855a9d36cfab9973764d0efb04a350" # sha1
gitlab_ce_version: "9.0.5"
gitlab_ce_checksum: "548f2f71bbe631db31391d6c1c7d96e12a238f7c" # sha1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Dependencies: base.yml, zone.yml
image_name: centos-6
image_desc: "Minimal CentOS 6 image with cloud-init"
image_homepage: "{{ image_base_homepage }}#centos-6"
image_homepage: "{{ image_contrib_homepage }}/centos-6.rst"
remove_base_image: true
builder_dir: "{{ builder.appliance.dir }}/centos-6"
builder_dir: "{{ builder.appliance.dir }}/contrib-centos-6"
builder_base_centos_imgmanifest: base-centos-6-latest.imgmanifest
builder_base_centos_imgfile: base-centos-6-latest.zfs.gz
builder_base_centos_imgmanifest_url: "{{ builder.appliance.url }}/base-centos-6/{{ builder_base_centos_imgmanifest }}"
builder_base_centos_imgfile_url: "{{ builder.appliance.url }}/base-centos-6/{{ builder_base_centos_imgfile }}"
base_centos_imgmanifest: "{{ lookup('pipe', 'curl -s {{ builder_base_centos_imgmanifest_url }}') | from_json }}"
zone_brand: kvm
zone_vnc_port: "{{ build_vnc_ports.centos6 | default(build_vnc_port) | mandatory }}"
zone_vnc_port: "{{ build_vnc_ports.contrib_centos6 | default(build_vnc_port) | mandatory }}"
zone_uuid: 92fafd5c-d6c9-11e4-bf58-c3f14a8e0832
zone_hostname: "{{ image_name }}"
zone_disks:
Expand All @@ -19,4 +19,4 @@ zone_disks:
image_size: "{{ base_centos_imgmanifest.image_size }}"
image_uuid: "{{ base_centos_imgmanifest.uuid }}"
refreservation: "{{ base_centos_imgmanifest.image_size }}"
zone_nic_0_ip: "{{ build_ips.centos6 | default(build_ip) }}"
zone_nic_0_ip: "{{ build_ips.contrib_centos6 | default(build_ip) }}"
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Dependencies: base.yml, zone.yml
image_name: centos-7
image_desc: "Minimal CentOS 7 image with cloud-init"
image_homepage: "{{ image_base_homepage }}#centos-7"
image_homepage: "{{ image_contrib_homepage }}/centos-7.rst"
remove_base_image: true
builder_dir: "{{ builder.appliance.dir }}/centos-7"
builder_dir: "{{ builder.appliance.dir }}/contrib-centos-7"
builder_base_centos_imgmanifest: base-centos-7-latest.imgmanifest
builder_base_centos_imgfile: base-centos-7-latest.zfs.gz
builder_base_centos_imgmanifest_url: "{{ builder.appliance.url }}/base-centos-7/{{ builder_base_centos_imgmanifest }}"
builder_base_centos_imgfile_url: "{{ builder.appliance.url }}/base-centos-7/{{ builder_base_centos_imgfile }}"
base_centos_imgmanifest: "{{ lookup('pipe', 'curl -s {{ builder_base_centos_imgmanifest_url }}') | from_json }}"
zone_brand: kvm
zone_vnc_port: "{{ build_vnc_ports.centos7 | default(build_vnc_port) | mandatory }}"
zone_vnc_port: "{{ build_vnc_ports.contrib_centos7 | default(build_vnc_port) | mandatory }}"
zone_uuid: 90f302a8-2934-11e5-98f7-d76e51783f66
zone_hostname: "{{ image_name }}"
zone_disks:
Expand All @@ -19,4 +19,4 @@ zone_disks:
image_size: "{{ base_centos_imgmanifest.image_size }}"
image_uuid: "{{ base_centos_imgmanifest.uuid }}"
refreservation: "{{ base_centos_imgmanifest.image_size }}"
zone_nic_0_ip: "{{ build_ips.centos7 | default(build_ip) }}"
zone_nic_0_ip: "{{ build_ips.contrib_centos7 | default(build_ip) }}"
Loading

0 comments on commit ca55996

Please sign in to comment.