• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Creating Task with TaskTypeManagement

    Scheduled Pinned Locked Moved Solved
    General Problems
    5
    23
    5.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cjenness
      last edited by

      I’m a noob, trying to create a Task so that I can do installs on specific server groups. I created a bootable Windows 2012 ISO with wimboot. This is closest post that I have found to my issue (https://forums.fogproject.org/topic/7448/adding-custom-task-to-fog-server?page=1). It is from last year, but the resolve doesn’t appear to have been posted, or I am not reading it correctly.

      My working FOG menu configuration is:
      “cpuid --ext 29 && set arch amd64 ||
      kernel http://${fog-ip}/win2012/${arch}/wimboot
      initrd http://${fog-ip}/win2012/${arch}/media/Boot/BCD BCD
      initrd http://${fog-ip}/win2012/${arch}/media/Boot/boot.sdi boot.sdi
      initrd http://${fog-ip}/win2012/${arch}/media/sources/boot.wim boot.wim
      boot ||”

      I read in the post mentioned above that I need to create a hook. Using /var/www/fog/lib/hooks/boottask.hook.php I’ve edited the $arguments but when I turn the hook on, I get a HTTP 500 Error. Once I have the hook configured how to I get the new task that I’ve created to call on it? Here is the part of the Hook that I edited.

      $arguments[‘ipxe’][‘task’][$TaskType->get(‘id’)] = array(
      ‘cpuid --ext 29 && set arch amd64 ||’,
      ‘kernel http://${fog-ip}/win2012/${arch}/wimboot’,
      ‘initrd http://${fog-ip}/win2012/${arch}/media/Boot/BCD’,
      ‘initrd http://${fog-ip}/win2012/${arch}/media/Boot/boot.sdi’,
      ‘initrd http://${fog-ip}/win2012/${arch}/media/sources/boot.wim’
      ‘boot ||’,
      );
      $arguments[‘Host’]
      ->get(‘task’)
      ->set(
      ‘stateID’,
      self::getCompleteState()
      )->save();

      I am trying to learn PHP while I do this, but don’t really know what I am doing.

      Thanks!

      1 Reply Last reply Reply Quote 0
      • george1421G
        george1421 Moderator
        last edited by

        Um, I think there is an easier way to go about this.

        There is a FOG plugin for creating custom tasks.

        Maybe you might explain a bit more about what your goal is and then we can work on a path.

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

        1 Reply Last reply Reply Quote 0
        • C
          cjenness
          last edited by

          Thanks for getting back to me. I have the task type management plugin installed, and I am trying to create a task so that I can boot the wimboot installer that I set up to install windows 2012 on a specific groups that I set up as needed.

          george1421G 1 Reply Last reply Reply Quote 0
          • george1421G
            george1421 Moderator @cjenness
            last edited by

            @cjenness I’m testing an idea at the moment to see if it works. I’ll get back to you. I haven’t done this exact thing just yet. But I have an idea without coding.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

            george1421G 1 Reply Last reply Reply Quote 0
            • george1421G
              george1421 Moderator @george1421
              last edited by

              @george1421 Well that didn’t work out as well as I thought.

              #!ipxe
              set fog-ip 192.168.112.24
              set fog-webroot fog
              set boot-url http://${fog-ip}/${fog-webroot}
              kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=127000 web=192.168.112.24/fog/ consoleblank=0 rootfstype=ext4 mac=b8:ca:3a:ce:1d:1a ftp=192.168.112.24 storage=192.168.112.24:/images/dev/ storageip=192.168.112.24 osid=0 irqpoll hostname=b8ca3ace1d1a fdrive=/dev/sdb initrd http://${fog-ip}/win2012/${arch}/media/Boot/BCD BCD;initrd http://${fog-ip}/win2012/${arch}/media/Boot/boot.sdi boot.sdi
              imgfetch init_32.xz
              boot
              
              

              It didn’t use my kernel definition and a bunch of unnecessary kernel parameters were added. We almost need to be able to deploy a fog ipxe menu. Its kind of close though.

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

              1 Reply Last reply Reply Quote 0
              • C
                cjenness
                last edited by

                I have an iPXE menu configured:

                “cpuid --ext 29 && set arch amd64 ||
                kernel http://${fog-ip}/win2012/${arch}/wimboot
                initrd http://${fog-ip}/win2012/${arch}/media/Boot/BCD BCD
                initrd http://${fog-ip}/win2012/${arch}/media/Boot/boot.sdi boot.sdi
                initrd http://${fog-ip}/win2012/${arch}/media/sources/boot.wim boot.wim
                boot ||”

                Which I can default boot, but I would like to be able to make that a task, so i can boot specific server groups.

                george1421G 1 Reply Last reply Reply Quote 0
                • george1421G
                  george1421 Moderator @cjenness
                  last edited by

                  @cjenness Yep I got that. That custom task function isn’t working as I “thought” it might. I’m still testing, but I think we might end up having to create a feature request for this action. I have see others post for something similar. Its a bit beyond the scope of what FOG was intended to do.

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                  1 Reply Last reply Reply Quote 0
                  • C
                    cjenness
                    last edited by

                    Thank you for taking the time to check on this for me.

                    Tom ElliottT 1 Reply Last reply Reply Quote 0
                    • Tom ElliottT
                      Tom Elliott @cjenness
                      last edited by

                      @cjenness The tasktypeedit plugin was designed to do this. It also means you may need to build your own hook to handle the more specifics.

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                      1 Reply Last reply Reply Quote 0
                      • Tom ElliottT
                        Tom Elliott
                        last edited by

                        Okay sorry thinking too much I think.

                        Seeing as you are getting error 500, can you provide your apache error logs?

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                        1 Reply Last reply Reply Quote 0
                        • Tom ElliottT
                          Tom Elliott
                          last edited by

                          I think the error is in the arguments.

                          Where is the $TaskType variable being set? (I’m guessing the 500 error will show something like:
                          Attempting to run non-existent method get on null at line ###).

                          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                          1 Reply Last reply Reply Quote 0
                          • C
                            cjenness
                            last edited by

                            I’ve actually fixed the 500 error. I was missing a comma after boot.wim in the hook in OP. But I am not sure how to get the task type manager to call the hook.

                            Tom ElliottT 1 Reply Last reply Reply Quote 0
                            • C
                              cjenness
                              last edited by

                              So for the hook, I have just been editing the file /var/www/fog/lib/hooks/boottask.hook.php. The only part I have edited so far are the arguments that I posted above.

                              Tom ElliottT 1 Reply Last reply Reply Quote 0
                              • Tom ElliottT
                                Tom Elliott @cjenness
                                last edited by

                                Can you paste the contents of the file (or upload the hook) here please?

                                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                1 Reply Last reply Reply Quote 0
                                • Tom ElliottT
                                  Tom Elliott @cjenness
                                  last edited by

                                  @cjenness Okay, if it’s the example, mark the active flag as true, that’s all you need to do.

                                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                  Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                  Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                  1 Reply Last reply Reply Quote 0
                                  • C
                                    cjenness
                                    last edited by Sebastian Roth

                                    Here is the entire file. So I have marked the flag as true and I no longer get the http 500 error, but I am not sure how to create a task with this hook.

                                    <?php
                                    /**
                                     * Alters the boot task to make a custom entry.
                                     *
                                     * PHP version 5
                                     *
                                     * @category BootTask
                                     * @package  FOGProject
                                     * @author   Tom Elliott <tommygunsster@gmail.com>
                                     * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
                                     * @link     https://fogproject.org
                                     */
                                    /**
                                     * Alters the boot task to make a custom entry.
                                     *
                                     * @category BootTask
                                     * @package  FOGProject
                                     * @author   Tom Elliott <tommygunsster@gmail.com>
                                     * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
                                     * @link     https://fogproject.org
                                     */
                                    class BootTask extends Hook
                                    {
                                        /**
                                         * The name of this hook.
                                         *
                                         * @var string
                                         */
                                        public $name = 'BootTask';
                                        /**
                                         * The description of this hook.
                                         *
                                         * @var string
                                         */
                                        public $description = 'Alter the boot task to make a custom task hook';
                                        /**
                                         * Is this hook active or not.
                                         *
                                         * @var bool
                                         */
                                        public $active = true;
                                        /**
                                         * Initializes object.
                                         *
                                         * @return void
                                         */
                                        public function __construct()
                                        {
                                            parent::__construct();
                                            self::$HookManager
                                                ->register(
                                                    'IPXE_EDIT',
                                                    array(
                                                        $this,
                                                        'changeTask'
                                                    )
                                                );
                                        }
                                        /**
                                         * Change the task.
                                         *
                                         * @param mixed $arguments The items to alter.
                                         *
                                         * @return void
                                         */
                                        public function changeTask($arguments)
                                        {
                                            if (!isset($arguments['ipxe']['task'])) {
                                                return;
                                            }
                                            $TaskType = self::getClass('TaskType')
                                                ->set('name', 'trusty-install')
                                                ->load('name');
                                            if (!$TaskType->isValid()) {
                                                return;
                                            }
                                            $keys = array_keys($arguments['ipxe']['task']);
                                            if (!in_array($TaskType->get('id'), $keys)) {
                                                return;
                                            }
                                            $arguments['ipxe']['task'][$TaskType->get('id')] = array(
                                                'cpuid --ext 29 && set arch amd64 ||',
                                                'kernel http://${fog-ip}/win2012/${arch}/wimboot',
                                                'initrd http://${fog-ip}/win2012/${arch}/media/Boot/BCD',
                                                'initrd http://${fog-ip}/win2012/${arch}/media/Boot/boot.sdi',
                                                'initrd http://${fog-ip}/win2012/${arch}/media/sources/boot.wim',
                                                'boot ||',
                                            );
                                            $arguments['Host']
                                                ->get('task')
                                                ->set(
                                                    'stateID',
                                                    self::getCompleteState()
                                                )->save();
                                        }
                                    }
                                    
                                    1 Reply Last reply Reply Quote 0
                                    • S
                                      Sebastian Roth Moderator
                                      last edited by

                                      @cjenness In the FOG web GUI click on one of your hosts or groups, then click ‘Basic tasks’ on the left and ‘Advanced’ to show all the tasks available. Do you see “BootTask” here?

                                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                      1 Reply Last reply Reply Quote 1
                                      • Tom ElliottT
                                        Tom Elliott
                                        last edited by

                                        Well the “BootTask” would be whatever task type was created. The “boottask” is just the hook that makes that hook operate.

                                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                        1 Reply Last reply Reply Quote 0
                                        • C
                                          cjenness
                                          last edited by

                                          Thank you guys for your help. So my question now is how do I tell the task type editor to use the hook that I just created?

                                          1 Reply Last reply Reply Quote 0
                                          • C
                                            cjenness
                                            last edited by

                                            Nevermind, I figured it out. You have to title your new task the name (trusty-install) in this portion.

                                            $TaskType = self::getClass(‘TaskType’)
                                            ->set(‘name’, ‘trusty-install’)
                                            ->load(‘name’);
                                            if (!$TaskType->isValid()) {
                                            return;

                                            1 Reply Last reply Reply Quote 1
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post

                                            254

                                            Online

                                            12.0k

                                            Users

                                            17.3k

                                            Topics

                                            155.2k

                                            Posts
                                            Copyright © 2012-2024 FOG Project