Class: ForemanAnsible::PlaybookCreator
- Inherits:
-
Object
- Object
- ForemanAnsible::PlaybookCreator
- Defined in:
- app/services/foreman_ansible/playbook_creator.rb
Overview
Service to generate a playbook given roles and a list of hosts
Instance Attribute Summary collapse
-
#role_names ⇒ Object
readonly
Returns the value of attribute role_names.
Instance Method Summary collapse
-
#initialize(role_names) ⇒ PlaybookCreator
constructor
A new instance of PlaybookCreator.
- #roles_playbook ⇒ Object
- #roles_tempfile ⇒ Object
Constructor Details
#initialize(role_names) ⇒ PlaybookCreator
Returns a new instance of PlaybookCreator.
6 7 8 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 6 def initialize(role_names) @role_names = role_names end |
Instance Attribute Details
#role_names ⇒ Object (readonly)
Returns the value of attribute role_names.
4 5 6 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 4 def role_names @role_names end |
Instance Method Details
#roles_playbook ⇒ Object
10 11 12 13 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 10 def roles_playbook playbook = ['hosts' => 'all', 'roles' => role_names] playbook.to_yaml end |
#roles_tempfile ⇒ Object
15 16 17 18 19 20 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 15 def roles_tempfile tempfile = Tempfile.new("foreman-ansible-#{fqdn}-roles") tempfile.write(roles_playbook) tempfile.close tempfile end |