Ejemplo n.º 1
0
 /**
  * @return PlayConfig[]
  * @throws InvalidConfigException
  */
 public function roles()
 {
     if (!isset($this->data['plays'])) {
         return [];
     }
     $plays = [];
     foreach ($this->data['plays'] as $playConfig) {
         if (!isset($playConfig['role'])) {
             throw new InvalidConfigException("Role field must be defined for every play");
         }
         $play = new PlayConfig(array_get($playConfig, 'name', $playConfig['role']));
         $play->setHosts(array_get($playConfig, 'hosts', 'all'));
         if (isset($playConfig['vars'])) {
             $play->addRole($playConfig['role'], (array) $playConfig['vars']);
         } else {
             $play->addRole($playConfig['role'], (array) array_except($playConfig, ['role', 'name', 'sudo', 'hosts', 'remote_user', 'tasks', 'handlers']));
         }
         $plays[] = $play;
     }
     return $plays;
 }
Ejemplo n.º 2
0
 /**
  * @param PlayConfig $play
  */
 public function add(PlayConfig $play)
 {
     $this->playbooks[$play->name()] = $play;
 }