public function shouldBePerformed(...$hosts)
    {
        // don't allow to run again it the task has been marked to run only once
        if ($this->once && $this->hasRun) {
            return false;
        }

        foreach ($hosts as $host) {
            $onHost = empty($this->on['hosts']) || in_array($host->getHostname(), $this->on['hosts'], true);

            $onRole = empty($this->on['roles']);
            foreach ((array) $host->get('roles', []) as $role) {
                if (in_array($role, $this->on['roles'], true)) {
                    $onRole = true;
                }
            }

            $onStage = empty($this->on['stages']);
            if ($host->has('stage')) {
                if (in_array($host->get('stage'), $this->on['stages'], true)) {
                    $onStage = true;
                }
            }

            if ($onHost && $onRole && $onStage) {
                return true;
            }
        }

        return empty($hosts);
    }
public function shouldBePerformed(...$hosts)
    {
        // don't allow to run again it the task has been marked to run only once
        if ($this->once && $this->hasRun) {
            return false;
        }

        foreach ($hosts as $host) {
            $onHost = empty($this->on['hosts']) || in_array($host->getHostname(), $this->on['hosts'], true);

            $onRole = empty($this->on['roles']);
            foreach ((array) $host->get('roles', []) as $role) {
                if (in_array($role, $this->on['roles'], true)) {
                    $onRole = true;
                }
            }

            $onStage = empty($this->on['stages']);
            if ($host->has('stage')) {
                if (in_array($host->get('stage'), $this->on['stages'], true)) {
                    $onStage = true;
                }
            }

            if ($onHost && $onRole && $onStage) {
                return true;
            }
        }

        return empty($hosts);
    }
public function shouldBePerformed ( ... $ hosts ) { // don't allow to run again it the task has been marked to run only once if ( $ this -> once && $ this -> hasRun ) { return false ; } foreach ( $ hosts as $ host ) { $ onHost = empty ( $ this -> on [ 'hosts' ] ) || in_array ( $ host -> getHostname ( ) , $ this -> on [ 'hosts' ] , true ) ; $ onRole = empty ( $ this -> on [ 'roles' ] ) ; foreach ( ( array ) $ host -> get ( 'roles' , [ ] ) as $ role ) { if ( in_array ( $ role , $ this -> on [ 'roles' ] , true ) ) { $ onRole = true ; } } $ onStage = empty ( $ this -> on [ 'stages' ] ) ; if ( $ host -> has ( 'stage' ) ) { if ( in_array ( $ host -> get ( 'stage' ) , $ this -> on [ 'stages' ] , true ) ) { $ onStage = true ; } } if ( $ onHost && $ onRole && $ onStage ) { return true ; } } return empty ( $ hosts ) ; }
Checks what task should be performed on one of hosts.

@param Host[] $hosts
@return bool
Checks what task should be performed on one of hosts .