def setup_server(): if not os.path.exists("/server/pypatcher-ansible/inventory"): raise RuntimeError("Server ip address not found (no inventroy file") out, err, rc = ansible_runner.run_command( executable_cmd="ansible-playbook", cmdline_args=[ "/server/pypatcher-ansible/setup-server.yml", "-i", "/server/pypatcher-ansible/inventory", "--private-key", "/root/.ssh/id_rsa", "-u", "root", "--extra-vars", "variable_host=all", ], input_fd=sys.stdin, output_fd=sys.stdout, error_fd=sys.stderr, ) print("rc: {}".format(rc)) print("out: {}".format(out)) print("err: {}".format(err)) return 'rc: {} \nout: {}\nerr: {}'.format(rc, out, err)
def install_pypatcher(): if not os.path.exists("/server/pypatcher-ansible/inventory"): raise RuntimeError("Server ip address not found (no inventroy file") # Change this to genuine file and pass in ENV vars or strings from NAW db entry out, err, rc = ansible_runner.run_command( executable_cmd="ansible-playbook", cmdline_args=[ "/server/pypatcher-ansible/install-pypatcher.yml", "-i", "/server/pypatcher-ansible/inventory", "--private-key", "/root/.ssh/id_rsa", "-u", "root", "--extra-vars", '"variable_host=all lounge_music_url={} icecast_server_url={} icecast_port={} icecast_mount={} icecast_password={}"' .format( LOUNGE_MUSIC_URL, ICECAST_SERVER_URL, ICECAST_PORT, ICECAST_MOUNT, ICECAST_PASSWORD, ), ], input_fd=sys.stdin, output_fd=sys.stdout, error_fd=sys.stderr, ) print("rc: {}".format(rc)) print("out: {}".format(out)) print("err: {}".format(err)) return 'rc: {} \nout: {}\nerr: {}'.format(rc, out, err)
def run(self) -> Tuple[str, str, int]: """Run command. :returns: Output, error, and error code """ self.generate_run_command_args() out, err, ret_code = run_command(**self._runner_args) return out, err, ret_code
def run(self) -> Tuple[str, str, int]: """run""" self.generate_run_command_args() out, err, ret_code = run_command(**self._runner_args) return out, err, ret_code
#!/usr/bin/env python import ansible_runner import sys # run ansible/generic commands in interactive mode within container out, err = ansible_runner.run_command( executable_cmd="ansible-playbook", cmdline_args=["/Users/tobias_sdnit/git/ansible-ee/project/test.yml", "-v"], input_fd=sys.stdin, output_fd=sys.stdout, error_fd=sys.stderr, cwd="/Users/tobias_sdnit/git/ansible-ee/", process_isolation=True, process_isolation_executable="docker", container_image="quay.io/tobiasjohanssonsdnit/ansible-ee", )