ansible-playbook is meant to run..... ansible playbooks :) What you have is a task file. Playbooks contain tasks. Playbook can import/include tasks files. To run a playbook you do need the playbook items such as hosts, tasks, etc.
On Fri, 9 Oct 2020 at 11:21, Mouton Noir <[email protected]> wrote: > > Hi, > > Newbie to Ansible, but I already made a lot of things with it. > One thing, though, I can't do is re-use a task file for adhoc commands or > re-use a playbook in another playbook : > > For example, I use a task file (R_packages.yml) in a role, that starts like > this : > > - name: Recuperation de la version de R installee > win_shell: (Get-ItemProperty > HKLM:Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object > DisplayName -like "R for Win*").DisplayVersion > register: Rversion > > I'd like to be able to launch it with an ad hoc command like : > ansible-playbook R_packages.yml ..... > But it doesn't work : > ERROR! 'register' is not a valid attribute for a Play > > I had to create a playbook to launch it : > - hosts: fst-win-tp-bio > gather_facts: "false" > tasks: > - name: Install packages R > import_tasks: /etc/ansible/roles/fst-win-tp-bio/tasks/R_packages.yml > > I didn't fond anything in the doc that makes me understand how I could make > an "hybrid" task/playbook file I could launch both ways > > To be clear : This task file is part of a role, and I like to be able to use > it from times to times on adhoc command. > > Thanks for your help > E.T. > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/e3b038d6-a99d-4b52-b02c-bdc8c9578c84n%40googlegroups.com. -- Dick Visser Trust & Identity Service Operations Manager GÉANT -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwOSdsimH5TQ8QZxDG-tM4Xf%3DtHuQZC64%3D%2BaLP-DVaPMtg%40mail.gmail.com.
