cancel
Showing results for 
Search instead for 
Did you mean: 
JohnAdams
Flight Engineer
Flight Engineer
  • 2,818 Views

Getting Satellite to run YAML

Jump to solution

I'm having some trouble getting Satellite to play this for me. I've formatted and reformatted. This YAML is directly analogous to what works from the command line:

 

- name: banner_recurse

  file: dest=/u01/app/banner state=directory owner=banner group=banmaint recurse=true

 

But it does not seem to register. When I run the job, it doesn't show as failed or as skipped, nothing like that. It just doesn't run.

Labels (2)
0 Kudos
2 Solutions

Accepted Solutions
Travis
Moderator
Moderator
  • 2,672 Views

@JohnAdams -

Which version of Satellite are you using and exactly how are you attempting to run this? I would suggest placing in a better YAML format and not having all options on the same line (even though it does work), as best practices for readability and debugging would have the options for the file module indented.

I'm assuming that you are wanting Satellite to execute this as an Ansible playbook or role against your systems, but again, it seems like you are running a job and not specifying if you have set up the job to run as an Ansible job and if you imported the YAML as an Ansible role.

One thing you could do is create the name of the Ansible role on the Satellite server and create the main.yml file in tasks. After that, you could import the role into Satellite as the banner_recurse role and let it be able to be assigned and run on any system.

 

/etc/ansible/roles/bannerrecurse/tasks/main.yml

 

- name: banner_recurse
    file:
      path: /u01/app/banner
      state: directory
      mode: '0755'
      owner: banner 
      group: banmaint
      recurse: yes

 

 

You could create and place the above file on the Satellite and import the Ansible role. This *should* work for your needs. The other thing to keep in mind for your example is there is no dest option for the file module (especially for directory) as you will want to use the path option instead.

You can get more creative here and test for the directories existence and register that and then only run this when the directory doesn't exist. 

I have some helpful information on how to do Ansible roles in Satellite at the following location.

https://github.com/tmichett/rh318_custom/blob/main/Playbooks/CH15/CH15-ge-ansible-remote-execution.y...

Hopefully, this answer makes sense and helps you on the correct path.

 

Travis 

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training

View solution in original post

Khamid
Flight Engineer Flight Engineer
Flight Engineer
  • 2,642 Views

You may run ansible-playbook command using verbose mode to get better output. 
```
ansible-playbook -vvv example.yml
```

View solution in original post

3 Replies
Travis
Moderator
Moderator
  • 2,673 Views

@JohnAdams -

Which version of Satellite are you using and exactly how are you attempting to run this? I would suggest placing in a better YAML format and not having all options on the same line (even though it does work), as best practices for readability and debugging would have the options for the file module indented.

I'm assuming that you are wanting Satellite to execute this as an Ansible playbook or role against your systems, but again, it seems like you are running a job and not specifying if you have set up the job to run as an Ansible job and if you imported the YAML as an Ansible role.

One thing you could do is create the name of the Ansible role on the Satellite server and create the main.yml file in tasks. After that, you could import the role into Satellite as the banner_recurse role and let it be able to be assigned and run on any system.

 

/etc/ansible/roles/bannerrecurse/tasks/main.yml

 

- name: banner_recurse
    file:
      path: /u01/app/banner
      state: directory
      mode: '0755'
      owner: banner 
      group: banmaint
      recurse: yes

 

 

You could create and place the above file on the Satellite and import the Ansible role. This *should* work for your needs. The other thing to keep in mind for your example is there is no dest option for the file module (especially for directory) as you will want to use the path option instead.

You can get more creative here and test for the directories existence and register that and then only run this when the directory doesn't exist. 

I have some helpful information on how to do Ansible roles in Satellite at the following location.

https://github.com/tmichett/rh318_custom/blob/main/Playbooks/CH15/CH15-ge-ansible-remote-execution.y...

Hopefully, this answer makes sense and helps you on the correct path.

 

Travis 

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training
JohnAdams
Flight Engineer
Flight Engineer
  • 2,660 Views

Hi, Travis Michette,

I had already taken most of your advice: I'm using the better-formatted way which you show above. The first was an artifact of command-line testing. And I'd corrected to path from dest.

I did indeed intend to make this a role, and could not see why it didn't work.

The big thing was doing something so obvious I didn't see it for a long time: I renamed my file main.yaml (rather than name_of_role.yaml) and everything went swimmingly. How embarassing to be able to write valid Ansible tasks yet not know how to name the file! I normally make better mistakes than that!

Thank you for your help, and especially the pointer to your GitHub examples! Super helpful.

Thanks,

John A

Khamid
Flight Engineer Flight Engineer
Flight Engineer
  • 2,643 Views

You may run ansible-playbook command using verbose mode to get better output. 
```
ansible-playbook -vvv example.yml
```

Join the discussion
You must log in to join this conversation.