Verify non-dockerized compass

Change-Id: I0f649a35d64b010a887f3a68b0eeaff7816364c3
This commit is contained in:
Jerry Zhao 2015-04-02 09:59:38 +08:00
parent 191771e32c
commit ad6a7afff8
8 changed files with 199 additions and 101 deletions

14
Vagrantfile vendored
View File

@ -12,6 +12,20 @@ Vagrant.configure("2") do |config|
ansible.playbook="install/allinone_nochef.yml"
end
end
config.vm.define :compass_nodocker do |compass_nodocker|
compass_nodocker.vm.box = "centos65"
compass_nodocker.vm.network :private_network, :ip=>"10.1.0.12", :libvirt__dhcp_enabled=>false
compass_nodocker.vm.provider :libvirt do |domain|
domain.memory = 4096
domain.cpus =4
domain.nested =true
domain.graphics_ip="0.0.0.0"
end
compass_nodocker.vm.provision "ansible" do |ansible|
ansible.playbook="install/compass_nodocker.yml"
# ansible.tags="debug"
end
end
config.vm.define :regtest_vm do |regtest_vm|
regtest_vm.vm.box = "centos65"
regtest_vm.vm.network :private_network, :ip=>"10.1.0.253", :libvirt__dhcp_enabled=>false

View File

@ -1,8 +1,10 @@
---
- hosts: compass_cobbler
- hosts: compass_nodocker
sudo: True
roles:
- common
- cobbler
- compass
vars:
- dockerized: False

View File

@ -5,10 +5,10 @@ rebuild: True
# Auto-generated IP values
chef_server: "10.145.89.139"
cobbler_server: "{{ internal_ip }}"
compass-server: "{{ internal_ip }}"
cobbler_server: "{{ mgmt_next_ip }}"
compass-server: "{{ mgmt_next_ip }}"
internal_nic: eth0
internal_nic: eth1
internal_interface: "ansible_{{ internal_nic }}"
internal_ip: "{{ hostvars[inventory_hostname][internal_interface]['ipv4']['address'] }}"
@ -47,10 +47,10 @@ compass0_router: "192.168.100.1"
compass0_dhcp_range: "192.168.100.150 192.168.100.160"
# management nic
mgmt_nic: "eth0"
mgmt_nic: "eth1"
mgmt_nic_ip: "hostvars[inventory_hostname][ansible_{{ mgmt_nic }}]['ipv4']['address']"
# management pxe server
mgmt_next_ip: "10.1.0.11"
mgmt_next_ip: "10.1.0.12"
# management subnet ip of the cluster you want to deploy
mgmt_subnet_ip: "10.1.0.0"
@ -140,7 +140,20 @@ ubuntu_1404_url: "https://s3-us-west-1.amazonaws.com/compass-local-repo/ubuntu/1
# ubuntu 14.04 os name
ubuntu_1404: "Ubuntu-14.04-x86_64"
region: "lab"
distros:
- {
name: "Ubuntu-14.04-x86_64",
iso_us_url: "https://s3-us-west-1.amazonaws.com/compass-local-repo/ubuntu/14.04/Ubuntu-14.04-x86_64.iso",
ppa_us_url: "https://s3-us-west-1.amazonaws.com/compass-local-repo/ubuntu/14.04/ubuntu_14_04_ppa_repo.tar.gz",
iso_lab_url: "http://192.168.110.2/cobbler/iso/ubuntu/Ubuntu-14.04-x86_64.iso",
ppa_lab_url: "http://192.168.110.2/cobbler/ppa_repo/ubuntu_14_04_ppa_repo.tar.gz",
ppa_repo_name: "ubuntu_14_04_ppa_repo",
breed: "ubuntu",
kickstart: "default.seed",
kopts: "netcfg/choose_interface=auto"
}
## volume mapping for cobbler ##
@ -186,6 +199,15 @@ docker_apt_key: 36A1D7869245C8950F966E92D8576A8BA88D21E9
# epel version
epel_file_name: epel-release-6-8.noarch.rpm
epel_base_url: http://download.fedoraproject.org/pub/epel/6/x86_64/
# atomic version
atomic_file_name: atomic-release-1.0-19.el6.art.noarch.rpm
atomic_base_url: http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/
# pxe boot macs
#pxe_boot_macs: ['00:00:37:ed:95:4e', '00:00:79:ad:ce:6b', '00:00:0a:f6:6e:d7']
#test: true
pxe_boot_macs: ['00:00:37:ed:95:4e', '00:00:79:ad:ce:6b', '00:00:0a:f6:6e:d7']
test: true
# the key to be authorized on pxe boot machines so passwordless login can be
# done from the machine where you grab the key.
push_ssh_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUuKnIXwxS9w+Rxb4+CL3iqNQXB+kriQyr89YeLg5X7B0h+r91okw2bgodVvoynH8n7d7afHYew4KH7pMc5a3QMf/gwhhnlfoeyimQg0IOTQ6pvNxifRi5IN9xa3mB3kL9/xVmfo9rUE6ZZ4dNQ91As706SLBzEJWUuICT7fFJqCqHbxNT9aO//TWcoJJH+d+GLfLagyfVxBHb8DcoNSKTq1rFjZCFVs9pg6aO0d6Z3FcyICxOaacsAoRZOsx8+2WsHaZRk6udbqZJHt7LBs9Bc38+YCRhc31Q2jyrm37xT3QchRl4sihqq38N03cTYBksuRfV1dJaso9MUQapa/Lv root@host-1"

View File

@ -11,6 +11,11 @@
register: epel_presence
ignore_errors: yes
- name: check atomic repo presence
command: rpm -q atomic-release
register: atomic_presence
ignore_errors: yes
#- name: get epel version
# command: >
# wget -q {{ epel_base_url }} -O - | grep -oE "(href=\"epel-release-6-[0-9,.].*)" | cut -d\" -f2
@ -21,6 +26,10 @@
yum: name={{ epel_base_url }}/{{ epel_file_name }} state=present
when: epel_presence.rc != 0
- name: install atomic repo
yum: name={{ atomic_base_url }}/{{ atomic_file_name }} state=present
when: atomic_presence.rc != 0
- name: yum update
yum: name=* state=latest update_cache=yes
@ -42,6 +51,7 @@
- tftp-server
- gcc
- httpd
- libselinux-python
- name: turn off iptables
service: name=iptables state=stopped enabled=no
@ -52,8 +62,12 @@
- { name: rsync, dest: /etc/xinetd.d/rsync }
- { name: debmirror.conf, dest: /etc/debmirror.conf }
- name: restart xinetd service
service: name=xinetd state=restarted enabled=yes
- name: configure interface for dhcp
command: ifconfig {{ mgmt_nic }}:1 {{ mgmt_next_ip }} netmask {{ mgmt_subnet_mask }}
when: not mgmt_ip_same
- name: copy httpd configuration files
file: src={{ item }} dest=/etc/httpd/conf.d/{{ item }} mode=0644
@ -87,23 +101,40 @@
git: repo={{ compass_adapter_source }}
dest=/opt/compass-adapters
version={{ compass_adapter_version }}
force=yes
update=no
# force=yes
- name: copy snippets to cobbler folder
command: cp -r /opt/compass-adapters/cobbler/{{ item }} /var/lib/cobbler/{{ item }}
- name: remove old cobbler folders
shell: rm -rf path=/var/lib/cobbler/{{ item }}
with_items:
- snippets
- scripts
- triggers
- kickstarts
- name: create cobbler folders
file: path=/var/lib/cobbler/{{ item }} state=directory mode=0755
with_items:
- snippets
- scripts
- triggers
- kickstarts
- name: copy snippets to cobbler folder
shell: cp -rf /opt/compass-adapters/cobbler/{{ item }}/* /var/lib/cobbler/{{ item }}/
with_items:
- snippets
- scripts
- triggers
- kickstarts
notify:
cobbler sync
- name: change snippets mode
file: path=/var/lib/cobbler mode=0755 recurse=yes
- name: copy default kickstart files
command: cp -r /opt/compass-adapters/cobbler/kickstarts/{{ item }} /var/lib/cobbler/kickstarts/{{ item }}
with_items:
- default.ks
- default.seed
- name: create cblr_ks folder
file: path=/var/www/cblr_ks mode=0755 state=directory
- name: change kickstart mode
file: path=/var/lib/cobbler/kickstarts mode=0666 recurse=yes
@ -115,48 +146,30 @@
command: echo 0 > /selinux/enforce
- name: create cobbler log directories
file: path={{ item }} mode=0644 state=directory recurse=yes
file: path={{ item }} mode=0777 state=directory recurse=yes
with_items:
# - /var/log/cobbler
- /var/log/cobbler
- /var/log/cobbler/anamon
- /var/log/cobbler/tasks
- name: create cobbler ppa repo dir
file: path=/var/lib/cobbler/{{ item }}
file: path=/var/lib/cobbler/repo_mirror/{{ item.ppa_repo_name }}/conf
state=directory
mode=0644
recurse=yes
with_items:
- repo_mirror/centos_6_5_ppa_repo
- repo_mirror/ubuntu_12_04_ppa_repo/conf
- repo_mirror/ubuntu_14_04_ppa_repo/conf
#- name: download centos ppa repo rpms
# get_url: url={{ item }}
# dest=/var/lib/cobbler/repo_mirror/centos_6_5_ppa_repo/
# with_items:
# - "{{ ntp }}"
# - "{{ ssh_client }}"
# - "{{ openssh }}"
# - "{{ iproute }}"
# - "{{ wget }}"
# - "{{ ntpdate }}"
# - "{{ yum_priorities }}"
# - "{{ jsonc }}"
# - "{{ libestr }}"
# - "{{ libgt }}"
# - "{{ liblogging }}"
# - "{{ rsyslog }}"
with_items: distros
- name: copy distributions to ubuntu ppa repo
template: src=distributions
dest=/var/lib/cobbler/repo_mirror/ubuntu_12_04_ppa_repo/conf/distributions
mode=0644
when: ubuntu_1204 in distros
- name: copy distribution to ubuntu 14.04 ppa repo
template: src=distributions
dest=/var/lib/cobbler/repo_mirror/ubuntu_14_04_ppa_repo/conf/distributions
mode=0644
when: ubuntu_1404 in distros
- name: start cobbler and httpd services
service: name={{ item }} state=restarted enabled=yes
@ -165,34 +178,39 @@
- cobblerd
- name: download ppa repo images
get_url: url={{ item.name }} dest=/var/lib/cobbler/repo_mirror/{{ item.filename }}.tar.gz
with_items:
- { name: "{{ centos_6_5_ppa_repo_url }}", filename: "centos_6_5_ppa_repo" }
- { name: "{{ ubuntu_12_04_ppa_repo_url }}", filename: "ubuntu_12_04_ppa_repo" }
- { name: "{{ ubuntu_14_04_ppa_repo_url }}", filename: "ubuntu_14_04_ppa_repo" }
get_url: url={{ item.ppa_lab_url }} dest=/var/lib/cobbler/repo_mirror/{{ item.ppa_repo_name }}.tar.gz
with_items: distros
when: region == "lab"
- name: download ppa repo images
get_url: url={{ item.ppa_us_url }} dest=/var/lib/cobbler/repo_mirror/{{ item.ppa_repo_name }}.tar.gz
with_items: distros
when: region == "us"
- name: untar ppa repo images
unarchive: src=/var/lib/cobbler/repo_mirror/{{ item }}.tar.gz
unarchive: src=/var/lib/cobbler/repo_mirror/{{ item.ppa_repo_name }}.tar.gz
dest=/var/lib/cobbler/repo_mirror/
copy=no
with_items:
- centos_6_5_ppa_repo
- ubuntu_12_04_ppa_repo
- ubuntu_14_04_ppa_repo
with_items: distros
- name: add repos
command: cobbler repo add --name {{ item }} --mirror=/var/lib/cobbler/repo_mirror/{{ item }} --mirror-locally=Y --arch=x86_64
with_items:
- centos_6_5_ppa_repo
- ubuntu_12_04_ppa_repo
- ubuntu_14_04_ppa_repo
command: cobbler repo add --name {{ item.ppa_repo_name }} --mirror=/var/lib/cobbler/repo_mirror/{{ item.ppa_repo_name }} --mirror-locally=Y --arch=x86_64
with_items: distros
args:
creates: /opt/repo_added.txt
ignore_errors: yes
run_once: True
- name: cobbler repo sync
command: cobbler reposync
- name: download loader files
get_url: url={{ cobbler_loaders_url }} dest=/var/lib/cobbler/
- name: untar loaders file
unarchive: src=/var/lib/cobbler/loaders.tar.gz dest=/var/lib/cobbler/
copy=no
- name: cobbler get loaders
command: cobbler get-loaders
@ -200,62 +218,66 @@
file: path=/var/lib/cobbler/iso state=directory
- name: download images
get_url: url={{ item.name }} dest=/var/lib/cobbler/iso/{{ item.filename }} mode=0644
with_items:
- { name: "{{ centos_url }}", filename: "{{ centos }}.iso" }
- { name: "{{ ubuntu_url }}", filename: "{{ ubuntu }}.iso" }
- { name: "{{ ubuntu_1404_url }}", filename: "{{ ubuntu_1404 }}.iso" }
get_url: url={{ item.iso_lab_url }} dest=/var/lib/cobbler/iso/{{ item.name }}.iso mode=0644
with_items: distros
when: region == "lab"
- name: download images
get_url: url={{ item.iso_us_url }} dest=/var/lib/cobbler/iso/{{ item.name }}.iso mode=0644
with_items: distros
when: region == "us"
- name: mount_info
command: mount
register: mount_info
- name: create mount point
file: name=/mnt/{{ item }} state=directory
with_items:
- "{{ centos }}"
- "{{ ubuntu }}"
- "{{ ubuntu_1404 }}"
when: mount_info.stdout.find('CentOS') == -1
file: name=/mnt/{{ item.name }} state=directory
with_items: distros
when: mount_info.stdout.find('CentOS') == -1 and mount_info.stdout.find('Ubuntu') == -1
ignore_errors: yes
- name: mount images
shell: mount -o loop /var/lib/cobbler/iso/{{ item }}.iso /mnt/{{ item }}
with_items:
- "{{ centos }}"
- "{{ ubuntu }}"
- "{{ ubuntu_1404 }}"
when: mount_info.stdout.find('CentOS') == -1
shell: mount -o loop /var/lib/cobbler/iso/{{ item.name }}.iso /mnt/{{ item.name }}
with_items: distros
when: mount_info.stdout.find('CentOS') == -1 and mount_info.stdout.find('Ubuntu') == -1
args:
creates: /opt/image_mounted.txt
ignore_errors: yes
run_once: True
- name: import distros
command: cobbler import --path=/mnt/{{ item.name }} --name {{ item.name }} --arch=x86_64 --kickstart=/var/lib/cobbler/kickstarts/default.ks --breed={{ item.breed }}
with_items:
- { name: "{{ centos }}", breed: redhat }
- { name: "{{ ubuntu }}", breed: ubuntu }
- { name: "{{ ubuntu_1404 }}", breed: ubuntu }
with_items: distros
args:
creates: /opt/distro_imported.txt
ignore_errors: yes
run_once: True
- name: add profiles
command: cobbler profile add --name={{ item.name }} --repo={{ item.repo }} --distro={{ item.name }} --ksmeta="tree=http://{{ mgmt_next_ip }}/cobbler/ks_mirror/{{ item.name }}" --kickstart=/var/lib/cobbler/kickstarts/{{ item.kickstart }} --kopts="{{ item.kopts }}"
with_items:
- { name: "{{ centos }}", repo: centos_6_5_ppa_repo, kickstart: default.ks, kopts: "" }
- { name: "{{ ubuntu }}", repo: ubuntu_12_04_ppa_repo, kickstart: default.seed, kopts: "netcfg/choose_interface=auto" }
- { name: "{{ ubuntu_1404 }}", repo: ubuntu_14_04_ppa_repo, kickstart: default.seed, kopts: "netcfg/choose_interface=auto"}
args:
creates: /opt/profile_added.txt
ignore_errors: yes
run_once: True
#- name: add profiles
# command: cobbler profile add --name={{ item.name }} --repo={{ item.ppa_repo_name }} --distro={{ item.name }} --ksmeta="tree=http://{{ mgmt_next_ip }}/cobbler/ks_mirror/{{ item.name }}" --kickstart=/var/lib/cobbler/kickstarts/{{ item.kickstart }} --kopts="{{ item.kopts }}"
# with_items: distros
# args:
# creates: /opt/profile_added.txt
# ignore_errors: yes
# run_once: True
- name: generate public key file for ssh
template: src=id_rsa.pub.j2 dest=/var/lib/cobbler/id_rsa.pub
when: push_ssh_key is defined
- name: generate ssh key for root
user: name=root generate_ssh_key=yes ssh_key_bits=2048 ssh_key_file=.ssh/id_rsa
when: push_ssh_key is not defined
- name: edit profiles
command: cobbler profile edit --name={{ item.name }} --repo={{ item.repo }} --distro={{ item.name }} --ksmeta="tree=http://{{ mgmt_next_ip }}/cobbler/ks_mirror/{{ item.name }}" --kickstart=/var/lib/cobbler/kickstarts/{{ item.kickstart }} --kopts="{{ item.kopts }}"
with_items:
- { name: "{{ centos }}", repo: centos_6_5_ppa_repo, kickstart: default.ks, kopts: "" }
- { name: "{{ ubuntu }}", repo: ubuntu_12_04_ppa_repo, kickstart: default.seed, kopts: "netcfg/choose_interface=auto" }
- { name: "{{ ubuntu_1404 }}", repo: ubuntu_14_04_ppa_repo, kickstart: default.seed, kopts: "netcfg/choose_interface=auto"}
shell: cobbler profile edit --name={{ item.name }} --repo={{ item.ppa_repo_name }} --distro={{ item.name }} --ksmeta="tree=http://{{ mgmt_next_ip }}/cobbler/ks_mirror/{{ item.name }}" --kickstart=/var/lib/cobbler/kickstarts/{{ item.kickstart }} --kopts="{{ item.kopts }}"
with_items: distros
- name: edit profiles with push ssh key option
shell: cobbler profile edit --name={{ item.name }} --repo={{ item.ppa_repo_name }} --distro={{ item.name }} --ksmeta="tree=http://{{ mgmt_next_ip }}/cobbler/ks_mirror/{{ item.name }} push_ssh_keys=/var/lib/cobbler/id_rsa.pub" --kickstart=/var/lib/cobbler/kickstarts/{{ item.kickstart }} --kopts="{{ item.kopts }}"
with_items: distros
when: push_ssh_key is defined
- name: remove ubuntu default repo
command: cobbler repo remove --name {{ item }}
@ -265,10 +287,16 @@
ignore_errors: yes
- name: cobbler repo sync again
command: cobbler reposync
shell: cobbler reposync
- name: cobler sync
command: cobbler sync
- name: cobbler sync
shell: cobbler sync
- name: restart xinetd
service: name=xinetd state=restarted
- name: restart dhcpd
service: name=dhcpd state=restarted
- name: cobbler check
command: cobbler check
shell: cobbler check

View File

@ -13,7 +13,7 @@ ddns-update-style interim;
allow booting;
allow bootp;
deny unknown-clients;
local-address {{ internal_ip }};
local-address {{ cobbler_server }};
log-facility local6;
ignore client-updates;
@ -26,6 +26,7 @@ option pxelinux.configfile code 209 = text;
option pxelinux.pathprefix code 210 = text;
option pxelinux.reboottime code 211 = unsigned integer 32;
{% if dockerized %}
subnet {{ compass0_subnet_ip }} netmask {{ compass0_subnet_mask }} {
option routers {{ compass0_router }};
option domain-name-servers {{ compass0_router }};
@ -48,6 +49,7 @@ subnet {{ compass0_subnet_ip }} netmask {{ compass0_subnet_mask }} {
}
}
{% endif %}
subnet {{ mgmt_subnet_ip }} netmask {{ mgmt_subnet_mask }} {
option routers {{ mgmt_router }};

View File

@ -0,0 +1 @@
{{ push_ssh_key }}

View File

@ -4,7 +4,12 @@ compass_adapter_version: dev/experimental
epel_file_name: epel-release-6-8.noarch.rpm
epel_base_url: http://download.fedoraproject.org/pub/epel/6/x86_64/
epel7_base_url: http://download.fedoraproject.org/pub/epel/7/x86_64/e/
cobbler_loaders_url: http://192.168.110.2/cobbler/loaders/loaders.tar.gz
ubuntu_14_04_ppa_repo_url: https://s3-us-west-1.amazonaws.com/compass-local-repo/ubuntu/14.04/ubuntu_14_04_ppa_repo.tar.gz
ubuntu_12_04_ppa_repo_url: https://s3-us-west-1.amazonaws.com/compass-local-repo/ubuntu/12.04/ubuntu_12_04_ppa_repo.tar.gz
centos_6_5_ppa_repo_url: https://s3-us-west-1.amazonaws.com/compass-local-repo/centos/6.5/centos_6_5_ppa_repo.tar.gz
mgmt_nic_ip: "{{ hostvars[inventory_hostname][mgmt_ansible_interface]['ipv4']['address'] }}"
mgmt_ansible_interface: "ansible_{{ mgmt_nic }}"
mgmt_ip_same: "{{ mgmt_nic_ip == mgmt_next_ip }}"
ppa_repo_url: "ppa_repo_{{ region }}_url"
iso_url: "iso_{{ region }}_url"

View File

@ -9,6 +9,12 @@
- name: check epel presence
command: rpm -q epel-release
register: epel_presence
ignore_errors: yes
- name: check atomic repo presence
command: rpm -q atomic-release
register: atomic_presence
ignore_errors: yes
#- name: get epel version
# command: 'wget -q {{ epel_base_url }} -O - |grep -oE "(href=\"epel-release-6-[0-9,.].*)" | cut -d'"' -f2'
@ -19,6 +25,10 @@
yum: name={{ epel_base_url }}/{{ epel_file_name }} state=present
when: epel_presence.rc != 0
- name: install atomic repo
yum: name={{ atomic_base_url }}/{{ atomic_file_name }} state=present
when: atomic_presence.rc != 0
- name: yum update
yum: name=* state=latest
@ -132,18 +142,24 @@
- name: add compass setting
template: src=compass.setting.j2 dest=/etc/compass/setting
notify:
restart compass service
- restart compass service
- restart http service
tags: debug
- name: add cobbler setting
template: src=cobbler.conf.nodocker.j2 dest=/etc/compass/os_installer/cobbler.conf
notify:
restart compass service
- restart compass service
- restart http service
- name: link celery bin file
file: src={{ COMPASS_PATH }}/venv/bin/celery dest=/opt/compass/bin/celery state=link
notify:
- restart compass service
- restart http service
- name: create redis folders
file: path={{ item }} state=directory owner=redis
file: path={{ item }} state=directory owner=redis group=root
with_items:
- /var/log/redis
- /var/lib/redis
@ -173,5 +189,13 @@
- name: copy web ui files
shell: cp -rf /opt/compass-web/v2 /var/www/compass_web/
- name: create switch file if test mode enabled
template: src=switch_machines_file.j2
dest=/etc/compass/switch_machines_file
when: test is defined and test == True
- name: inject switches and mac addresses
shell: /opt/compass/bin/manage_db.py set_switch_machines --switch_machines_file /etc/compass/switch_machines_file
when: test is defined and test == True
#- name: run compass check
# command: compass check