Skip to content

add checksums (and trivial changes) from upstream #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: sofia-lab
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Ansible/group_vars/all
*.pyc
.vscode/*
18 changes: 14 additions & 4 deletions Ansible/deployvms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
connection: local
gather_facts: no
tasks:
- name: Ensure cmk is pointing to the right env
shell: cmk set profile cloudstack

- name: Capture build date
set_fact: env_builddate="{{lookup('pipe','date +%d/%m/%y_%H:%M')}}"

Expand Down Expand Up @@ -62,17 +65,17 @@
# Create build project if it doesn't exist.
- name: Create project
include: tasks/updateproject.yml project_tag=Deploying_VMs

- name: Capture all accounts in domain
shell: cs listAccounts listall=true | jq -c -r '.account[] | select(.domain == "ROOT")' | jq -c -r '.name' | sed -e ':a;N;$!ba;s/\n/,/g'
shell: cmk listAccounts listall=true | jq -c -r '.account[] | select(.domain == "ROOT")' | jq -c -r '.name' | sed -e ':a;N;$!ba;s/\n/,/g'
register: allaccts_retval

- name: get projectid
shell: cs listProjects | jq -c '.project[] | select(.name | contains("{{ build_project }}"))' | jq '.id'
shell: cmk listProjects | jq -c '.project[] | select(.name | contains("{{ build_project }}"))' | jq '.id'
register: projectid

- name: Add accounts to project
shell: "cs addAccountToProject account={{ item }} projectid={{ projectid.stdout }}"
shell: "cmk addAccountToProject account={{ item }} projectid={{ projectid.stdout }}"
with_items:
- "{{ allaccts_retval.stdout.split(',') }}"

Expand Down Expand Up @@ -237,6 +240,13 @@
roles:
- cloudstack-config

- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: create mavin cfg file
template: src=advanced-cfg.j2 dest="./{{ env_name_clean }}-advanced-cfg"

## update status

- hosts: localhost
Expand Down
7 changes: 6 additions & 1 deletion Ansible/destroyvms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
# gather_facts: no
# tasks:
# - name: Deregister Licensed XenServers
# shell: xe host-license-remove host-uuid=`xe host-list --minimal hostname=$HOSTNAME`
# shell: xe host-license-remove host-uuid=`xe host-list --minimal hostname=$HOSTNAME`
# ignore_errors: true

- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Ensure cmk is pointing to the right env
shell: cmk set profile cloudstack

- include: ./tasks/removeproject.yml

- hosts: primary_storage_hosts
Expand Down Expand Up @@ -40,13 +43,15 @@
env_db_manage: DBHOST={{ env_db_ip }} DBUSER={{ env_db_user }} DBPASS={{ env_db_password }} DBNAME={{ env_db_name }} ENV_UUID={{ env_uuid }} ENV_NAME={{ env_name_clean }} ENV_COMMENT='{{ env_comment }}' ENV_ACTION=rel
register: db_manage_output
when: not destroy_forced
# ignore_errors: true

- debug:
msg: "{{ db_manage_output }}"

- name: Check for environments db failure
fail: msg="Environment not successfully released - {{ env_return }} {{ env_retmsg }}."
when: env_return != "success"
# ignore_errors: true

- name: Update inventory file - remove server IP addresses
replace:
Expand Down
23 changes: 13 additions & 10 deletions Ansible/generate-cloudconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
versionstring: "{{ env_dotted_version }}"
register: cs_version_data
when: env_dotted_version is defined

- debug: msg="{{ cs_version_data }}"

- name: Check returned environment name
Expand Down Expand Up @@ -207,12 +207,12 @@

- name: set value for additional zone if not defined
set_fact:
additional_zone: no
additional_zone: no
when: additional_zone is not defined

- name: set value for additional pod if not defined
set_fact:
additional_pod: no
additional_pod: no
when: additional_pod is not defined

- name: ensure existing_zone is given when env is an additional pod
Expand Down Expand Up @@ -252,15 +252,15 @@
# messy but necessary check.

- debug:
msg: "{{ env_version }}"
msg: "{{ env_cs_minor_version_string }}"

- name: set mgmt java version
set_fact:
java_ver: "{{ java_vers[env_version] }}"
java_ver: "{{ java_vers[env_cs_minor_version_string] }}"

- debug:
msg: "{{ java_ver }}"

- name: Set mgmt os fact
set_fact:
mgmt_os_name: "{{ linux_os[mgmt_os].os }}"
Expand Down Expand Up @@ -315,8 +315,11 @@
- debug: msg="{{ dbcheck }}"

# now do stuff
- name: Ensure cmk is pointing to the right env
shell: cmk set profile cloudstack

- name: Capture account name
shell: cs listAccounts
shell: cmk listAccounts
register: acct_retval

- name: Register authenticating account
Expand Down Expand Up @@ -361,14 +364,14 @@

- name: Build group_vars file
template: src=templates/nestedgroupvars.j2 dest="{{ inventory_dir }}/group_vars/{{ env_name_clean }}"

- name: check group_vars are OK (read in the file)
shell: "cat {{ inventory_dir }}/group_vars/{{ env_name_clean }}"
register: group_vars_file

- name: check group_vars are OK (look for curly braces)
fail:
msg: "Curly braces found in group_vars, some var could not be evaluated. Stopping"
when: group_vars_file.stdout.find("templating_succeeded") == -1

- debug: msg="You can now run{{":"}} ansible-playbook deployvms.yml -i ./hosts_{{ env_name_clean }} "
12 changes: 8 additions & 4 deletions Ansible/group_vars/all.sample
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def_management_vm_hypervisor: "VMware"
def_build_zone: "<ZONE_NAME_HERE>"
def_build_keyboard: "uk"
parent_vcenter_dc: "<PARENT_VC_DC_NAME_HERE>"
repohost: "http://<IP_ADDRESS_HERE>"
os_repo: "http://<IP_ADDRESS_HERE>"
sb_repo: "http://<IP_ADDRESS_HERE>"
custom_repo: "http://<IP_ADDRESS_HERE>"
def_env_timezone: "UTC"
def_use_external_hv_hosts: no
def_use_phys_hosts: no
Expand Down Expand Up @@ -147,6 +149,7 @@ def_local_storage_disk_offering: "Custom"
def_local_storage_disk_size: "80"
def_use_s3: no
def_setshortname: no
hypervisors_on_same_host: no

base_version_of_master: cs413

Expand Down Expand Up @@ -710,7 +713,7 @@ def_vmware_templates:
vc_template: "vCenter 5.1u2d"
55u3:
esxi_template: "ESXi 5.5u3"
vc_template: "vCenter 55u3"
vc_template: "vCenter 5.5u3"
60u2:
esxi_template: "ESXi 6.0u2"
vc_template: "vCenter 60u2"
Expand All @@ -722,7 +725,7 @@ def_vmware_templates:
vc_template: "vCenter 65u1"
"65u2":
esxi_template: "ESXi 6.5u1"
vc_template: "vCenter-65u2"
vc_template: "vCenter 65u2"
"67u0":
esxi_template: "ESXi 6.7.0"
vc_template: "vCenter 67u0"
Expand Down Expand Up @@ -784,6 +787,7 @@ def_marvin_tests_source: "github"
def_marvin_tests_github_source: "https://github.com/apache/cloudstack"
def_marvin_images_location: "http://<IP_ADDRESS_HERE>/marvin"
def_openvm_images_location: "http://<IP_ADDRESS_HERE>/openvm"
def_cks_images_location: "http://<IP_ADDRESS_HERE>/cks"
def_fallback_marvin_test_repo: "http://<IP_ADDRESS_HERE>/shapeblue/cloudstack/upstream/centos7/4.13/"

# Webhooks for integration
Expand Down Expand Up @@ -879,7 +883,7 @@ global_settings:
- {name: "vm.destroy.forcestop", value: "true", condition: "marvin"}
- {name: "vpc.max.networks", value: "5", condition: "marvin"}
- {name: "router.redundant.vrrp.interval", value: "1", condition: "marvin"}
- {name: "router.aggregation.command.each.timeout", value: "10", condition: "marvin"}
- {name: "router.aggregation.command.each.timeout", value: "120", condition: "marvin"}
dvswitch:
- {name: "vmware.use.dvswitch", value: "true", condition: "dvswitch"}
systemvmlocalstorage:
Expand Down
28 changes: 21 additions & 7 deletions Ansible/library/custom_allocator
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,28 @@ function least_cluster_mem()
LOWESTCLUSTERNAME=`cmk list clusters id=$LOWESTCLUSTERID | jq -r '.cluster[] | .name'`
}

function least_host()
function least_host_cpu()
{
HOSTUSE=`cmk list hosts type=routing | jq '.host[]' | sed 's/\%//'`
HOSTUSE=`cmk list hosts type=routing state=Up resourcestate=Enabled | jq '.host[]' | sed 's/\%//'`
LOWESTHOSTID=`echo $HOSTUSE | jq -r -s -c 'sort_by(.cpuused|tonumber) | .[0] | .id'`
LOWESTCLUSTERID=`echo $HOSTUSE | jq -r -s -c 'sort_by(.cpuused|tonumber) | .[0] | .clusterid'`
LOWESTHOSTNAME=`cmk list hosts id=$LOWESTHOSTID | jq -r '.host[] | .name'`
LOWESTCLUSTERNAME=`cmk list clusters id=$LOWESTCLUSTERID | jq -r '.cluster[] | .name'`
}

function least_host_mem()
{
HOSTUSE=`cmk list hosts type=routing state=Up resourcestate=Enabled | jq '.host[]' | sed 's/\%//'`
LOWESTHOSTID=`echo $HOSTUSE | jq -r -s -c 'sort_by(.memoryused) | .[0] | .id'`
LOWESTCLUSTERID=`echo $HOSTUSE | jq -r -s -c 'sort_by(.memoryused) | .[0] | .clusterid'`
LOWESTHOSTNAME=`cmk list hosts id=$LOWESTHOSTID | jq -r '.host[] | .name'`
LOWESTCLUSTERNAME=`cmk list clusters id=$LOWESTCLUSTERID | jq -r '.cluster[] | .name'`
}

function least_host_in_cluster()
{
HOSTUSE=`cmk list hosts type=routing clusterid=$CLUSTERID| jq '.host[]' | sed 's/\%//'`
LOWESTHOSTID=`echo $HOSTUSE | jq -r -s -c 'sort_by(.cpuused|tonumber) | .[0] | .id'`
HOSTUSE=`cmk list hosts type=routing state=Up resourcestate=Enabled | jq '.host[]' | sed 's/\%//'`
LOWESTHOSTID=`echo $HOSTUSE | jq -r -s -c 'sort_by(.memoryused) | .[0] | .id'`
LOWESTHOSTNAME=`cmk list hosts id=$LOWESTHOSTID | jq -r '.host[] | .name'`
}

Expand Down Expand Up @@ -77,13 +86,18 @@ LOWESTPODID=""
## DO STUFF

case "$ALGORITHM" in
least_host)
least_host;
least_host_cpu)
least_host_cpu;
MSG="Returning lowest used host in zone"
ReturnFact;
;;
least_host_mem)
least_host_mem;
MSG="Returning lowest used host in zone"
ReturnFact;
;;
least_host_least_cluster)
least_cluster;
least_cluster_mem;
CLUSTERID=${LOWESTCLUSTERID}
least_host_in_cluster;
MSG="Returning lowest used host in lowest used cluster in zone"
Expand Down
6 changes: 3 additions & 3 deletions Ansible/library/env_db_manage
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ WriteOutput "Name check - found ${env_name_count} with name ${ENV_NAME}";
#
function countEnvAvailable()
{
COUNTPODENVS=`${MYSQLCOMMAND} "SELECT COUNT(*) FROM ${DBNAME}.${PODTBL} WHERE inuse='FALSE' and removed IS NOT NULL"`
COUNTPUBLICENVS=`${MYSQLCOMMAND} "SELECT COUNT(*) FROM ${DBNAME}.${PUBTBL} WHERE inuse='FALSE' and removed IS NOT NULL"`
COUNTGUESTENVS=`${MYSQLCOMMAND} "SELECT COUNT(*) FROM ${DBNAME}.${GUESTTBL} WHERE inuse='FALSE' and removed IS NOT NULL"`
COUNTPODENVS=`${MYSQLCOMMAND} "SELECT COUNT(*) FROM ${DBNAME}.${PODTBL} WHERE inuse='FALSE'"`
COUNTPUBLICENVS=`${MYSQLCOMMAND} "SELECT COUNT(*) FROM ${DBNAME}.${PUBTBL} WHERE inuse='FALSE'"`
COUNTGUESTENVS=`${MYSQLCOMMAND} "SELECT COUNT(*) FROM ${DBNAME}.${GUESTTBL} WHERE inuse='FALSE'"`
WriteOutput "Environments count: ${COUNTPODENVS} podnets, ${COUNTPUBLICENVS} pubnets, ${COUNTGUESTENVS} guestnets";
}

Expand Down
6 changes: 3 additions & 3 deletions Ansible/library/os_facts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

OS_DIST="NotFound"
OS_VER="NotFound"
if [ -h "/etc/redhat-release" ]; then
if [ -e "/etc/redhat-release" ]; then
OS_DIST="CentOS"
if [ "`cat cat /etc/*-release | grep 'VERSION_ID='`" == "" ]; then
if [ "`cat /etc/*-release | grep 'VERSION_ID='`" == "" ]; then
OS_VER=`cat /etc/*-release | grep -i 'centos' | awk -F ' ' '{print $3}' | sed 's/\"//g' | head -1`
OS_VER_MAJOR=`echo $OS_VER | awk -F '.' '{print $1}'`
else
Expand All @@ -31,4 +31,4 @@ cat << EOF
}
EOF

exit
exit
1 change: 1 addition & 0 deletions Ansible/roles/cloudmonkey/tasks/centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
url: "{{ def_linux_cm_url }}"
dest: /usr/bin/cmk
mode: 0755
timeout: 30

- name: link cmk to cloudmonkey
file:
Expand Down
1 change: 1 addition & 0 deletions Ansible/roles/cloudmonkey/tasks/centos8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
url: "{{ def_linux_cm_url }}"
dest: /usr/bin/cmk
mode: 0755
timeout: 30

- name: link cmk to cloudmonkey
file:
Expand Down
3 changes: 3 additions & 0 deletions Ansible/roles/cloudmonkey/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@

- include: ./ubuntu.yml
when: ansible_distribution == 'Ubuntu'

- include: ./suse.yml
when: ansible_distribution == 'SUSE'
46 changes: 46 additions & 0 deletions Ansible/roles/cloudmonkey/tasks/suse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---

#Copyright 2016-2021 ShapeBlue
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.

- name: install jq
zypper:
name: jq
state: latest

- name: ensure cm config is removed
file: path=/root/.cloudmonkey/config state=absent

- name: copy CloudMonkey to host
get_url:
url: "{{ def_linux_cm_url }}"
dest: /usr/bin/cmk
mode: 0755
timeout: 30

- name: link cmk to cloudmonkey
file:
src: /usr/bin/cmk
dest: /usr/bin/cloudmonkey
state: link

- name: create .cmk directory
file:
path: /root/.cmk
state: directory
mode: 0755

- name: base configuration
shell: "cmk set prompt 'cmk-SB>' ; cmk set log_file /var/log/cloud-cli.log ; cmk set apikey {{ cm_apikey }} ; cmk set secretkey {{ cm_secretkey }} ; cmk set url http://{{ hostvars[groups['primary_cs_manager'][0]]['ansible_ssh_host'] }}:8080/client/api"
ignore_errors: true
3 changes: 2 additions & 1 deletion Ansible/roles/cloudmonkey/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#limitations under the License.

- name: update apt-get
command: apt-get update
command: apt-get update

- name: install setup tools and jq
apt: pkg={{ item }} state=present
Expand All @@ -30,6 +30,7 @@
url: "{{ def_linux_cm_url }}"
dest: /usr/bin/cmk
mode: 0755
timeout: 30

- name: link cmk to cloudmonkey
file:
Expand Down
2 changes: 1 addition & 1 deletion Ansible/roles/cloudstack-config/templates/deployzone.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ then
then
WriteOutput "Adding VMware cluster."
{% if env_numversion | version_compare('4.2','>') %}
cloudmonkey add cluster zoneid=${ZoneID} hypervisor='VMware' clustertype='ExternalManaged' podid=${PodID} url="http://{% if groups['vc_hosts'] | length | int > 0 %}{{ hostvars[groups['vc_hosts'][0]]['ansible_ssh_host'] }}{% else %}UNDEFINED{% endif %}/{{ vmware_datacenter_name }}/{{ env_zone_clustername }}" clustername="{{ env_zone_clustername }}" vsmipaddress="{% if groups['vc_hosts'] | length | int > 0 %}{{ hostvars[groups['vc_hosts'][0]]['ansible_ssh_host'] }}{% else %}UNDEFINED{% endif %}" vsmpassword='{{ vmware_vcsa_pass }}' vsmusername='{{ vmware_vcsa_user }}' | tee -i -a ${DEPLOYLOG};
cloudmonkey add cluster zoneid=${ZoneID} hypervisor='VMware' clustertype='ExternalManaged' podid=${PodID} url="http://{% if groups['vc_hosts'] | length | int > 0 %}{{ hostvars[groups['vc_hosts'][0]]['ansible_ssh_host'] }}{% else %}UNDEFINED{% endif %}/{{ vmware_datacenter_name }}/{{ env_zone_clustername }}" clustername="{{ env_zone_clustername }}" vsmipaddress="{% if groups['vc_hosts'] | length | int > 0 %}{{ hostvars[groups['vc_hosts'][0]]['ansible_ssh_host'] }}{% else %}UNDEFINED{% endif %}" password='{{ vmware_vcsa_pass }}' username='{{ vmware_vcsa_user }}' vsmpassword='{{ vmware_vcsa_pass }}' vsmusername='{{ vmware_vcsa_user }}' | tee -i -a ${DEPLOYLOG};
{% else %}
cloudmonkey add cluster zoneid=${ZoneID} hypervisor='VMware' clustertype='ExternalManaged' podid=${PodID} url="http://{% if groups['vc_hosts'] | length | int > 0 %}{{ hostvars[groups['vc_hosts'][0]]['ansible_ssh_host'] }}{% else %}UNDEFINED{% endif %}/{{ vmware_datacenter_name }}/{{ env_zone_clustername }}" clustername="{{ env_zone_clustername }}" password='{{ vmware_vcsa_pass }}' username='{{ vmware_vcsa_user }}' | tee -i -a ${DEPLOYLOG};
{% endif %}
Expand Down
Loading