issue #239: ansible: ignore remote_tmp in new style runner.

pull/240/head
David Wilson 7 years ago
parent 94e048a2e5
commit 3203846708

@ -110,9 +110,9 @@ class Runner(object):
def get_temp_dir(self): def get_temp_dir(self):
if not self._temp_dir: if not self._temp_dir:
self._temp_dir = ansible_mitogen.target.make_temp_directory( self._temp_dir = tempfile.mkdtemp(prefix='ansible_mitogen_')
self.remote_tmp, # https://github.com/dw/mitogen/issues/239
) #ansible_mitogen.target.make_temp_directory(self.remote_tmp)
return self._temp_dir return self._temp_dir
def setup(self): def setup(self):

@ -9,4 +9,5 @@
- import_playbook: connection_loader/all.yml - import_playbook: connection_loader/all.yml
- import_playbook: context_service/all.yml - import_playbook: context_service/all.yml
- import_playbook: playbook_semantics/all.yml - import_playbook: playbook_semantics/all.yml
- import_playbook: remote_tmp/all.yml
- import_playbook: runner/all.yml - import_playbook: runner/all.yml

@ -0,0 +1,2 @@
- import_playbook: readonly_homedir.yml

@ -0,0 +1,21 @@
# https://github.com/dw/mitogen/issues/239
# While remote_tmp is used in the context of the SSH user by action code
# running on the controller, Ansiballz ignores it and uses the system default
# instead.
- name: integration/remote_tmp/readonly_homedir.yml
hosts: test-targets
any_errors_fatal: true
tasks:
- custom_python_detect_environment:
become: true
become_user: mitogen__readonly_homedir
register: out
vars:
ansible_become_pass: readonly_homedir_password
- debug: msg={{out}}
- name: Verify system temp directory was used.
assert:
that:
- out.argv[0].startswith("/tmp/ansible_mitogen_")

@ -51,6 +51,7 @@
- require_tty - require_tty
- pw_required - pw_required
- require_tty_pw_required - require_tty_pw_required
- readonly_homedir
when: ansible_system == 'Darwin' when: ansible_system == 'Darwin'
- name: Create Mitogen test users - name: Create Mitogen test users
@ -84,6 +85,9 @@
with_sequence: start=1 end=21 with_sequence: start=1 end=21
when: ansible_distribution == 'MacOSX' when: ansible_distribution == 'MacOSX'
- name: Readonly homedir for one account
shell: "chown -R root: ~mitogen__readonly_homedir"
- name: Require a TTY for two accounts - name: Require a TTY for two accounts
lineinfile: lineinfile:
path: /etc/sudoers path: /etc/sudoers
@ -101,12 +105,13 @@
- mitogen__pw_required - mitogen__pw_required
- mitogen__require_tty_pw_required - mitogen__require_tty_pw_required
- name: Allow passwordless for one account - name: Allow passwordless for two accounts
lineinfile: lineinfile:
path: /etc/sudoers path: /etc/sudoers
line: "{{lookup('pipe', 'whoami')}} ALL = ({{item}}) NOPASSWD:ALL" line: "{{lookup('pipe', 'whoami')}} ALL = ({{item}}) NOPASSWD:ALL"
with_items: with_items:
- mitogen__require_tty - mitogen__require_tty
- mitogen__readonly_homedir
- name: Allow passwordless for many accounts - name: Allow passwordless for many accounts
lineinfile: lineinfile:

@ -46,6 +46,8 @@ RUN \
useradd -s /bin/bash -m mitogen__pw_required && \ useradd -s /bin/bash -m mitogen__pw_required && \
useradd -s /bin/bash -m mitogen__require_tty && \ useradd -s /bin/bash -m mitogen__require_tty && \
useradd -s /bin/bash -m mitogen__require_tty_pw_required && \ useradd -s /bin/bash -m mitogen__require_tty_pw_required && \
useradd -s /bin/bash -m mitogen__readonly_homedir && \
chown -R root: ~mitogen__readonly_homedir && \
{ for i in `seq 1 21`; do useradd -s /bin/bash -m mitogen__user$i; done; } && \ { for i in `seq 1 21`; do useradd -s /bin/bash -m mitogen__user$i; done; } && \
( echo 'root:rootpassword' | chpasswd; ) && \ ( echo 'root:rootpassword' | chpasswd; ) && \
( echo 'mitogen__has_sudo:has_sudo_password' | chpasswd; ) && \ ( echo 'mitogen__has_sudo:has_sudo_password' | chpasswd; ) && \
@ -55,6 +57,7 @@ RUN \
( echo 'mitogen__pw_required:pw_required_password' | chpasswd; ) && \ ( echo 'mitogen__pw_required:pw_required_password' | chpasswd; ) && \
( echo 'mitogen__require_tty:require_tty_password' | chpasswd; ) && \ ( echo 'mitogen__require_tty:require_tty_password' | chpasswd; ) && \
( echo 'mitogen__require_tty_pw_required:require_tty_pw_required_password' | chpasswd; ) && \ ( echo 'mitogen__require_tty_pw_required:require_tty_pw_required_password' | chpasswd; ) && \
( echo 'mitogen__readonly_homedir:readonly_homedir_password' | chpasswd; ) && \
mkdir ~mitogen__has_sudo_pubkey/.ssh && \ mkdir ~mitogen__has_sudo_pubkey/.ssh && \
{ echo '#!/bin/bash\nexec strace -ff -o /tmp/pywrap$$.trace python2.7 "$@"' > /usr/local/bin/pywrap; chmod +x /usr/local/bin/pywrap; } { echo '#!/bin/bash\nexec strace -ff -o /tmp/pywrap$$.trace python2.7 "$@"' > /usr/local/bin/pywrap; chmod +x /usr/local/bin/pywrap; }

Loading…
Cancel
Save