Skip to content

Instantly share code, notes, and snippets.

@evrardjp
Created April 27, 2017 07:41
Show Gist options
  • Save evrardjp/9d0c48f2e31834d1bac17cfda26328bf to your computer and use it in GitHub Desktop.
Save evrardjp/9d0c48f2e31834d1bac17cfda26328bf to your computer and use it in GitHub Desktop.
import yaml
files_to_open = [
'user_osa_variables_defaults_cleaned.yml',
'user_osa_variables_overrides_cleaned.yml',
'user_rpco_variables_defaults_cleaned.yml',
'user_rpco_variables_overrides_cleaned.yml',
]
resulting_file = 'assertions.yml'
with open(resulting_file,'w+') as wf:
for filename in files_to_open:
with open(filename,'r') as f:
loaded = yaml.load(f.read())
for key, value in loaded.iteritems():
if type(value) is str:
value = "'{}'".format(value)
wf.write('- "{} == {}"\n'.format(key, value))
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- template:
src: "{{ item }}"
dest: "./{{ item | basename }}"
with_items:
- rpcd/etc/openstack_deploy/user_osa_variables_defaults.yml
- rpcd/etc/openstack_deploy/user_osa_variables_overrides.yml
- rpcd/etc/openstack_deploy/user_rpco_variables_defaults.yml
- rpcd/etc/openstack_deploy/user_rpco_variables_overrides.yml
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- assert:
that:
- "nova_db_max_pool_size == '120'"
- "neutron_metering_agent_ini_overrides == {'DEFAULT': {'interface_driver': 'neutron.agent.linux.interface.BridgeInterfaceDriver'}}"
- "ssh_delay == 60"
- "cinder_service_backup_program_enabled == False"
- "db_max_pool_size == 120"
- "ceph_apt_pinned_packages == [{'release': 'RedHat', 'priority': 995, 'package': '*'}]"
- "rpc_conn_pool_size == 180"
- "neutron_db_pool_timeout == '60'"
- "glance_glance_api_conf_overrides == {'DEFAULT': {'image_cache_dir': 'None'}}"
- "cinder_rpc_executor_thread_pool_size == '180'"
- "db_pool_timeout == 60"
- "osa_secrets_file_name == 'user_osa_secrets.yml'"
- "horizon_custom_uploads == {'logo': {'dest': 'img/logo.png', 'src': '/opt/rpc-openstack/logo_files/logo.png'}, 'logo-splash': {'dest': 'img/logo-splash.png', 'src': '/opt/rpc-openstack/logo_files/logo-splash.png'}, 'favicon': {'dest': 'img/favicon.ico', 'src': '/opt/rpc-openstack/logo_files/favicon.ico'}}"
- "db_max_overflow == 60"
- "keystone_token_driver == 'sql'"
- "rpc_response_timeout == 180"
- "neutron_rpc_thread_pool_size == '180'"
- "cinder_rpc_response_timeout == '180'"
- "rabbitmq_ulimit == 65535"
- "glance_flavor == 'keystone'"
- "nova_ram_allocation_ratio == 1.0"
- "neutron_rpc_response_timeout == '180'"
- "nova_db_max_overflow == '60'"
- "neutron_db_max_overflow == '60'"
- "neutron_api_workers == 64"
- "nova_api_db_pool_timeout == '60'"
- "nova_console_type == 'novnc'"
- "rpc_thread_pool_size == 180"
- "nova_db_pool_timeout == '60'"
- "neutron_db_max_pool_size == '120'"
- "openstack_release == 'r14.0.0rc1'"
- "pkg_locations == ['../', '/etc/ansible/roles', '/etc/openstack_deploy', '/opt/rpc-openstack/rpcd']"
- "keystone_database_max_pool_size == '120'"
- "nova_api_db_max_overflow == '60'"
- "neutron_l2_population == True"
- "memcached_connections == 16384"
- "nova_rpc_thread_pool_size == '180'"
- "rackspace_static_files_folder == '/opt/rpc-openstack/logo_files'"
- "keystone_database_pool_timeout == '60'"
- "galera_cluster_name == 'rpc_galera_cluster'"
- "neutron_legacy_ha_tool_enabled == True"
- "repo_build_pip_extra_indexes == ['https://rpc-repo.rackspace.com/pools']"
- "neutron_rpc_conn_pool_size == '180'"
- "neutron_neutron_conf_overrides == {'DEFAULT': {'l3_ha': False}}"
- "haproxy_extra_services == [{'service': {'haproxy_balance_type': 'http', 'haproxy_service_name': 'elasticsearch', 'haproxy_backend_options': ['httpchk /healthcheck'], 'haproxy_backend_nodes': '[]', 'haproxy_ssl': False, 'haproxy_port': 9200}}, {'service': {'haproxy_balance_type': 'tcp', 'haproxy_service_name': 'kibana_ssl', 'haproxy_backend_options': ['ssl-hello-chk'], 'haproxy_backend_nodes': '[]', 'haproxy_ssl': False, 'haproxy_port': 8443}}]"
- "nova_rpc_conn_pool_size == '180'"
- "nova_rpc_response_timeout == '180'"
- "nova_cpu_allocation_ratio == 2.0"
- "repo_build_upper_constraints_overrides == ['elasticsearch==2.3.0']"
- "nova_api_db_max_pool_size == '120'"
- "this_file_is_reserved_for_support == True"
- "ceph_stable_repo == 'http://download.ceph.com/debian-jewel/'"
- "maas_scheme == 'https'"
- "maas_auth_method == 'password'"
- "rackspace_cloud_username == 'SomeUserName'"
- "rackspace_cloud_password == 'SomeUsersPassword'"
- "pool_default_size == 3"
- "remote_check == True"
- "maas_notification_plan == 'npManaged'"
- "mon_osd_full_ratio == 0.9"
- "fetch_directory == '/etc/openstack_deploy/ceph_fetch'"
- "rpc_release == 'r14.0.0rc1'"
- "maas_alarm_remote_consecutive_count == 1"
- "mon_osd_nearfull_ratio == 0.8"
- "maas_alarm_local_consecutive_count == 3"
- "rackspace_cloud_auth_url == 'https://identity.api.rackspacecloud.com/v2.0'"
- "cloud_resource_cpu_allocation_ratio == '2.0'"
- "ssl_check == False"
- "maas_username == 'SomeUserName'"
- "maas_monitor_cinder_backup == 'False'"
- "maas_check_period_override == {'disk_utilisation': 900}"
- "maas_target_alias == 'public0_v4'"
- "rpc_repo_path == '/opt/rpc-openstack/openstack-ansible'"
- "journal_size == 80000"
- "maas_auth_token == 'some_token'"
- "secure_cluster == True"
- "generate_fsid == False"
- "pool_default_min_size == 2"
- "maas_api_key == 'SomeAPIKey'"
- "maas_excluded_alarms == ['^idle_percent_average.*', '^memory_used.*', '^alarm-network-receive.*', '^alarm-network-transmit.*']"
- "secure_cluster_flags == ['nodelete']"
- "fsid == ''"
- "check_firewall == False"
- "rackspace_cloud_api_key == 'SomeAPIKey'"
- "maas_excluded_checks == ['horizon_local_check.*']"
- "openstack_config == True"
- "cloud_resource_mem_allocation_ratio == '1.0'"
- "ceph_stable == True"
- "maas_filesystem_critical_threshold == 90.0"
- "maas_auth_url == 'https://identity.api.rackspacecloud.com/v2.0'"
- "rackspace_cloud_tenant_id == 'SomeTenantID'"
- "maas_tenant_id == 'SomeTenantID'"
- "ceph_stable_release == 'jewel'"
- "host_check == False"
- "maas_filesystem_warning_threshold == 80.0"
- "raw_multi_journal == True"
- "this_file_is_reserved_for_support == True"
@evrardjp
Copy link
Author

templating vars templates the user vars for creating real life assertions. (We can't extract vars like that).
Then we format them in a proper ansible assertion with the python script.

We insert the generated assertions into a playbook that will be using the group vars to see if these match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment