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.
8 9 10 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 8 def initialize(role_names) @role_names = role_names end |
Instance Attribute Details
#role_names ⇒ Object (readonly)
Returns the value of attribute role_names.
6 7 8 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 6 def role_names @role_names end |
Instance Method Details
#roles_playbook ⇒ Object
12 13 14 15 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 12 def roles_playbook playbook = ['hosts' => 'all', 'roles' => role_names] playbook.to_yaml end |
#roles_tempfile ⇒ Object
17 18 19 20 21 22 |
# File 'app/services/foreman_ansible/playbook_creator.rb', line 17 def roles_tempfile tempfile = Tempfile.new("foreman-ansible-#{fqdn}-roles") tempfile.write(roles_playbook) tempfile.close tempfile end |