Is it possible to call ansible or ansible-playbook directly on a target host using a script or ansible itself?

I need to know if it's possible to call / execute ansible playbooks from the target machine. I think i saw a vendor do it or at least something similar. they downloaded a script and it did ran the playbook.

if this is possible how would it be done?

my goal is to run ansible as a centralized server in aws to perform tasks in mulitple environments. most are behind firewalls, any reccomendations/thoughts would be appreciated.

Sure. If your host will install Ansible on target and feed it with all the playbooks the you can run it as any other executable. Should you do that is another story but technically there's no obstacle.

Intro to Playbooks — Ansible Documentation, AnsibleFest is going virtual with two days of expert speakers, live demos and be a programming language or script, but rather a model of a configuration or a process. of hosts to some well defined roles, represented by things ansible calls tasks. a playbook of multiple 'plays', it is possible to orchestrate multi- machine� Patterns and ansible-playbook flags ¶ You can change the behavior of the patterns defined in playbooks using command-line options. For example, you can run a playbook that defines hosts: all on a single host by specifying -i 127.0.0.2,. This works even if the host you target is not defined in your inventory.

You can run ansible and ansible playbook as you would any other binary on the target's $PATH, so any tool that facilitates running remote commands would work.

Because you are in AWS, one way might be to use AWS System's Manager.

If you wanted to use Ansible itself to do this you could use the shell or command modules:

- hosts: target
  become: false
  gather_facts: false
  tasks:
  - name: ansible in ansible
    command: ansible --version

  - name: ansible-playbook in ansible
    command: ansible-playbook --version

Though, as with any situation where you reach for the shell or command modules, you have to be vigilant to maintain playbook idempotency yourself.

If you're requirement is just the ability to execute Ansible commands remotely, you might look into AWX which is the upstream project for Red Hat's Ansible Tower. It wraps ansible in a nice user interface to allow you to trigger Ansible playbooks remotely and with nice-to-haves like RBAC.

Frequently Asked Questions — Ansible Documentation, AnsibleFest is going virtual with two days of expert speakers, live demos and I set the PATH or any other environment variable for a task or entire playbook?� so you can use this for custom modules written in any scripting language and Python interpret cannot be found in default location /usr/bin/python on target host. ansible-playbook playbook.yml -l www.example.com Limit option docs: Limit to one or more hosts This is required when one wants to run a playbook against a host group, but only against one or more members of that group. Limit to one host. ansible-playbook playbooks/PLAYBOOK_NAME.yml --limit "host1" Limit to multiple hosts

If you're ok with executing tasks remotely over ssh take a look at Sparrowdo it has out of the box facilities to run bash scripts ( read ansible executable ) remotely from one master host to another. Or you can even use it to install all the ansible dependencies or whatever you need to do for your scope.

Ansible playbook shell command examples, ansible playbook shell command examples ansible是一种自动化运维工具, I use Mac, and have setup a virtual window 10 host via VMware fusion. you need it directly I want to be able to provide data to a command via stdin in my ansible playbooks. For example, in a bash script that calls ansible: Apr 28, 2018 � Ansible� ansible-playbook user.yml --extra-vars "target = "<your host variable>" If {{ target }} isn't defined, the playbook does nothing. A group from the hosts file can also be passed through if need be. This does not harm if the extra vars is not provided. Playbook targeting a single host $ ansible-playbook user.yml --extra-vars "target = <your hosts

Ansible Tutorial | Ansible Playbooks And Adhoc Commands, Ansible Tutorial – Learn To Write Ansible Playbooks which machines in your infrastructure to target and which remote user to complete the tasks. To include hosts in Ansible inventory, we will be using the IP These are modules that the core Ansible team maintains and will always ship with Ansible itself. The PATH to the inventory, which defaults to /etc/ansible/hosts. Alternatively, you can use a comma-separated list of hosts or a single host with a trailing comma host,. And when I run ansible-playbook without inventory, it says: [WARNING]: provided hosts list is empty, only localhost is available

Ansible roles and tasks in same playbook, Sep 01, 2017 � Any copy, script, template or include tasks (in the role) can reference files Ansible uses declarative YML “playbooks” to map a group of hosts (from 19 Feb 2016 Roles allow you to call a set of variables, tasks, and handlers by simply 0 you are able to use with_ loops and task includes (but not playbook� the above example requires the lsb_release package on the target host in order to return the ‘lsb major_release’ fact. Variables defined in the playbooks or inventory can also be used, just make sure to apply the |bool filter to non boolean variables (ex: string variables with content like ‘yes’, ‘on’, ‘1’, ‘true’).

The ansible-pull is a small script that will checkout a repo of configuration instructions from git, and then run ansible-playbook against that content. Assuming you load balance your checkout location, ansible-pull scales essentially infinitely. Run ansible-pull--help for details.