diff --git a/tests/README.md b/tests/README.md index f5bbbc41..11a87022 100644 --- a/tests/README.md +++ b/tests/README.md @@ -73,7 +73,7 @@ also by Ansible's `osx_setup.yml`. used to target this account, the parent session requires a TTY and the account password must be entered. -`mitogen__user1` .. `mitogen__user21` +`mitogen__user1` .. `mitogen__user5` These accounts do not have passwords set. They exist to test the Ansible interpreter recycling logic. diff --git a/tests/image_prep/_user_accounts.yml b/tests/image_prep/_user_accounts.yml index 0167a09f..0c1f6045 100644 --- a/tests/image_prep/_user_accounts.yml +++ b/tests/image_prep/_user_accounts.yml @@ -9,8 +9,12 @@ strategy: mitogen_linear become: true vars: + distro: "{{ansible_distribution}}" + ver: "{{ansible_distribution_major_version}}" + special_users: - has_sudo + - has_sudo_nopw - has_sudo_pubkey - pw_required - readonly_homedir @@ -19,10 +23,10 @@ - slow_user - webapp - groups: - - has_sudo: ['mitogen__group', '{{sudo_group[distro]}}'] - - has_sudo_pubkey: ['mitogen__group', '{{sudo_group[distro]}}'] - - has_sudo_nopw: ['mitogen__group', 'mitogen__sudo_nopw'] + user_groups: + has_sudo: ['mitogen__group', '{{sudo_group[distro]}}'] + has_sudo_pubkey: ['mitogen__group', '{{sudo_group[distro]}}'] + has_sudo_nopw: ['mitogen__group', 'mitogen__sudo_nopw'] normal_users: "{{ lookup('sequence', 'start=1 end=5 format=user%d', wantlist=True) @@ -53,14 +57,14 @@ - user: name: "mitogen__{{item}}" shell: /bin/bash - groups: "{{groups[item]|default(['mitogen__group'])}}" + groups: "{{user_groups[item]|default(['mitogen__group'])}}" password: "{{ (item + '_password') | password_hash('sha256') }}" loop: "{{all_users}}" when: ansible_system != 'Darwin' - user: name: "mitogen__{{item}}" shell: /bin/bash - groups: "{{groups[item]|default(['mitogen__group'])}}" + groups: "{{user_groups[item]|default(['mitogen__group'])}}" password: "{{item}}_password" loop: "{{all_users}}" when: ansible_system == 'Darwin' diff --git a/tests/image_prep/build_docker_images.py b/tests/image_prep/build_docker_images.py index 44c4e2dd..c085d29e 100755 --- a/tests/image_prep/build_docker_images.py +++ b/tests/image_prep/build_docker_images.py @@ -23,9 +23,11 @@ def sh(s, *args): label_by_id = {} -for base_image, label in [('debian:stretch', 'debian'), - ('centos:6', 'centos6'), - ('centos:7', 'centos7')]: +for base_image, label in [ + ('debian:stretch', 'debian'), + ('centos:6', 'centos6'), + ('centos:7', 'centos7') + ]: args = sh('docker run --rm -it -d -h mitogen-%s %s /bin/bash', label, base_image) container_id = subprocess.check_output(args).strip()