2018-11-06 13:47:09 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
2019-07-23 16:25:53 +00:00
|
|
|
import sys
|
2018-11-06 13:47:09 +00:00
|
|
|
|
|
|
|
import ci_lib
|
|
|
|
|
|
|
|
|
|
|
|
project_dir = os.path.join(ci_lib.TMP, 'project')
|
|
|
|
vars_path = 'ansible/inventory/group_vars/debops_all_hosts.yml'
|
|
|
|
inventory_path = 'ansible/inventory/hosts'
|
|
|
|
docker_hostname = ci_lib.get_docker_hostname()
|
|
|
|
|
|
|
|
|
|
|
|
with ci_lib.Fold('docker_setup'):
|
2024-09-25 11:19:39 +00:00
|
|
|
containers = ci_lib.container_specs(
|
|
|
|
['debian*2'],
|
|
|
|
base_port=2700,
|
|
|
|
name_template='debops-target-%(distro)s-%(index)d',
|
|
|
|
)
|
2018-11-06 13:47:09 +00:00
|
|
|
ci_lib.start_containers(containers)
|
|
|
|
|
|
|
|
|
|
|
|
with ci_lib.Fold('job_setup'):
|
|
|
|
ci_lib.run('debops-init %s', project_dir)
|
|
|
|
os.chdir(project_dir)
|
|
|
|
|
2020-10-25 23:51:39 +00:00
|
|
|
ansible_strategy_plugin = "{}/ansible_mitogen/plugins/strategy".format(ci_lib.GIT_ROOT)
|
|
|
|
|
2018-11-06 13:47:09 +00:00
|
|
|
with open('.debops.cfg', 'w') as fp:
|
|
|
|
fp.write(
|
|
|
|
"[ansible defaults]\n"
|
2020-10-25 23:51:39 +00:00
|
|
|
"strategy_plugins = {}\n"
|
2018-11-06 13:47:09 +00:00
|
|
|
"strategy = mitogen_linear\n"
|
2020-10-25 23:51:39 +00:00
|
|
|
.format(ansible_strategy_plugin)
|
2018-11-06 13:47:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
with open(vars_path, 'w') as fp:
|
|
|
|
fp.write(
|
|
|
|
"ansible_python_interpreter: /usr/bin/python2.7\n"
|
|
|
|
"\n"
|
|
|
|
"ansible_user: mitogen__has_sudo_pubkey\n"
|
|
|
|
"ansible_become_pass: has_sudo_pubkey_password\n"
|
|
|
|
"ansible_ssh_private_key_file: %s\n"
|
|
|
|
"\n"
|
|
|
|
# Speed up slow DH generation.
|
|
|
|
"dhparam__bits: ['128', '64']\n"
|
2019-02-18 19:58:54 +00:00
|
|
|
% (ci_lib.key_file,)
|
2018-11-06 13:47:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
with open(inventory_path, 'a') as fp:
|
|
|
|
fp.writelines(
|
|
|
|
'%(name)s '
|
|
|
|
'ansible_host=%(hostname)s '
|
|
|
|
'ansible_port=%(port)d '
|
2018-11-07 01:16:18 +00:00
|
|
|
'ansible_python_interpreter=%(python_path)s '
|
2018-11-06 13:47:09 +00:00
|
|
|
'\n'
|
|
|
|
% container
|
|
|
|
for container in containers
|
|
|
|
)
|
|
|
|
|
2021-11-10 22:34:32 +00:00
|
|
|
ci_lib.dump_file('ansible/inventory/hosts')
|
2018-11-06 13:47:09 +00:00
|
|
|
|
|
|
|
# Now we have real host key checking, we need to turn it off
|
|
|
|
os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False'
|
|
|
|
|
|
|
|
|
2019-08-09 19:19:16 +00:00
|
|
|
interesting = ci_lib.get_interesting_procs()
|
|
|
|
|
2018-11-06 13:47:09 +00:00
|
|
|
with ci_lib.Fold('first_run'):
|
2019-07-23 16:25:53 +00:00
|
|
|
ci_lib.run('debops common %s', ' '.join(sys.argv[1:]))
|
2018-11-06 13:47:09 +00:00
|
|
|
|
2019-08-09 19:19:16 +00:00
|
|
|
ci_lib.check_stray_processes(interesting, containers)
|
|
|
|
|
2018-11-06 13:47:09 +00:00
|
|
|
|
|
|
|
with ci_lib.Fold('second_run'):
|
2019-07-23 16:25:53 +00:00
|
|
|
ci_lib.run('debops common %s', ' '.join(sys.argv[1:]))
|
2019-08-09 19:19:16 +00:00
|
|
|
|
|
|
|
ci_lib.check_stray_processes(interesting, containers)
|