Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Jobs #80

Open
mattschwen opened this issue Apr 26, 2021 · 6 comments
Open

Running Jobs #80

mattschwen opened this issue Apr 26, 2021 · 6 comments

Comments

@mattschwen
Copy link

Can you run jobs and retrieve their status with this library? Seems this is just for creating, modifying, and deleting objects. How about running job templates?

@costastf
Copy link
Collaborator

@costastf
Copy link
Collaborator

The api supported already is fully documented at https://towerlib.readthedocs.io/en/latest/modules.html .

@mattschwen
Copy link
Author

mattschwen commented Apr 28, 2021

Hey @costastf this library is awesome and does provide an awesome framework to implement a fully supported python library for the AWX API. The options for launching a job are pretty limited, we should add every option that the AWX CLI supports really. For launching a job that would be the same options as here https://github.com/ansible/awx/blob/devel/awxkit/awxkit/api/pages/job_templates.py#L41

I may want to contribute this, need to see how much work it would take.

        optional_fields = (
            'ask_scm_branch_on_launch',
            'ask_credential_on_launch',
            'ask_diff_mode_on_launch',
            'ask_inventory_on_launch',
            'ask_job_type_on_launch',
            'ask_limit_on_launch',
            'ask_skip_tags_on_launch',
            'ask_tags_on_launch',
            'ask_variables_on_launch',
            'ask_verbosity_on_launch',
            'allow_simultaneous',
            'become_enabled',
            'diff_mode',
            'force_handlers',
            'forks',
            'host_config_key',
            'job_tags',
            'limit',
            'skip_tags',
            'start_at_task',
            'survey_enabled',
            'timeout',
            'use_fact_cache',
            'vault_credential',
            'verbosity',
            'job_slice_count',
            'webhook_service',
            'webhook_credential',
            'scm_branch')

@mattschwen
Copy link
Author

AWX API Job Templates post options

 "POST": {
            "name": {
                "type": "string",
                "required": true,
                "label": "Name",
                "max_length": 512,
                "help_text": "Name of this job template.",
                "filterable": true
            },
            "description": {
                "type": "string",
                "required": false,
                "label": "Description",
                "help_text": "Optional description of this job template.",
                "filterable": true,
                "default": ""
            },
            "job_type": {
                "type": "choice",
                "required": false,
                "label": "Job type",
                "filterable": true,
                "default": "run",
                "choices": [
                    [
                        "run",
                        "Run"
                    ],
                    [
                        "check",
                        "Check"
                    ]
                ]
            },
            "inventory": {
                "type": "id",
                "required": false,
                "label": "Inventory",
                "filterable": true
            },
            "project": {
                "type": "id",
                "required": false,
                "label": "Project",
                "filterable": true
            },
            "playbook": {
                "type": "string",
                "required": false,
                "label": "Playbook",
                "max_length": 1024,
                "filterable": true,
                "default": ""
            },
            "scm_branch": {
                "type": "string",
                "required": false,
                "label": "Scm branch",
                "help_text": "Branch to use in job run. Project default used if blank. Only allowed if project allow_override field is set to true.",
                "max_length": 1024,
                "filterable": true,
                "default": ""
            },
            "forks": {
                "type": "integer",
                "required": false,
                "label": "Forks",
                "min_value": 0,
                "max_value": 2147483647,
                "filterable": true,
                "default": 0
            },
            "limit": {
                "type": "string",
                "required": false,
                "label": "Limit",
                "filterable": true,
                "default": ""
            },
            "verbosity": {
                "type": "choice",
                "required": false,
                "label": "Verbosity",
                "filterable": true,
                "default": 0,
                "choices": [
                    [
                        0,
                        "0 (Normal)"
                    ],
                    [
                        1,
                        "1 (Verbose)"
                    ],
                    [
                        2,
                        "2 (More Verbose)"
                    ],
                    [
                        3,
                        "3 (Debug)"
                    ],
                    [
                        4,
                        "4 (Connection Debug)"
                    ],
                    [
                        5,
                        "5 (WinRM Debug)"
                    ]
                ]
            },
            "extra_vars": {
                "type": "json",
                "required": false,
                "label": "Extra vars",
                "filterable": true,
                "default": ""
            },
            "job_tags": {
                "type": "string",
                "required": false,
                "label": "Job tags",
                "max_length": 1024,
                "filterable": true,
                "default": ""
            },
            "force_handlers": {
                "type": "boolean",
                "required": false,
                "label": "Force handlers",
                "filterable": true,
                "default": false
            },
            "skip_tags": {
                "type": "string",
                "required": false,
                "label": "Skip tags",
                "max_length": 1024,
                "filterable": true,
                "default": ""
            },
            "start_at_task": {
                "type": "string",
                "required": false,
                "label": "Start at task",
                "max_length": 1024,
                "filterable": true,
                "default": ""
            },
            "timeout": {
                "type": "integer",
                "required": false,
                "label": "Timeout",
                "help_text": "The amount of time (in seconds) to run before the task is canceled.",
                "min_value": -2147483648,
                "max_value": 2147483647,
                "filterable": true,
                "default": 0
            },
            "use_fact_cache": {
                "type": "boolean",
                "required": false,
                "label": "Use fact cache",
                "help_text": "If enabled, Tower will act as an Ansible Fact Cache Plugin; persisting facts at the end of a playbook run to the database and caching facts for use by Ansible.",
                "filterable": true,
                "default": false
            },
            "host_config_key": {
                "type": "string",
                "required": false,
                "label": "Host config key",
                "max_length": 1024,
                "filterable": true,
                "default": ""
            },
            "ask_scm_branch_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask scm branch on launch",
                "filterable": true,
                "default": false
            },
            "ask_diff_mode_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask diff mode on launch",
                "filterable": true,
                "default": false
            },
            "ask_variables_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask variables on launch",
                "filterable": true,
                "default": false
            },
            "ask_limit_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask limit on launch",
                "filterable": true,
                "default": false
            },
            "ask_tags_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask tags on launch",
                "filterable": true,
                "default": false
            },
            "ask_skip_tags_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask skip tags on launch",
                "filterable": true,
                "default": false
            },
            "ask_job_type_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask job type on launch",
                "filterable": true,
                "default": false
            },
            "ask_verbosity_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask verbosity on launch",
                "filterable": true,
                "default": false
            },
            "ask_inventory_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask inventory on launch",
                "filterable": true,
                "default": false
            },
            "ask_credential_on_launch": {
                "type": "boolean",
                "required": false,
                "label": "Ask credential on launch",
                "filterable": true,
                "default": false
            },
            "survey_enabled": {
                "type": "boolean",
                "required": false,
                "label": "Survey enabled",
                "filterable": true,
                "default": false
            },
            "become_enabled": {
                "type": "boolean",
                "required": false,
                "label": "Become enabled",
                "filterable": true,
                "default": false
            },
            "diff_mode": {
                "type": "boolean",
                "required": false,
                "label": "Diff mode",
                "help_text": "If enabled, textual changes made to any templated files on the host are shown in the standard output",
                "filterable": true,
                "default": false
            },
            "allow_simultaneous": {
                "type": "boolean",
                "required": false,
                "label": "Allow simultaneous",
                "filterable": true,
                "default": false
            },
            "custom_virtualenv": {
                "type": "string",
                "required": false,
                "label": "Custom virtualenv",
                "help_text": "Local absolute file path containing a custom Python virtualenv to use",
                "max_length": 100,
                "filterable": true,
                "default": null
            },
            "job_slice_count": {
                "type": "integer",
                "required": false,
                "label": "Job slice count",
                "help_text": "The number of jobs to slice into at runtime. Will cause the Job Template to launch a workflow if value is greater than 1.",
                "min_value": 0,
                "max_value": 2147483647,
                "filterable": true,
                "default": 1
            },
            "webhook_service": {
                "type": "choice",
                "required": false,
                "label": "Webhook service",
                "help_text": "Service that webhook requests will be accepted from",
                "filterable": true,
                "choices": [
                    [
                        "",
                        "---------"
                    ],
                    [
                        "github",
                        "GitHub"
                    ],
                    [
                        "gitlab",
                        "GitLab"
                    ]
                ]
            },
            "webhook_credential": {
                "type": "id",
                "required": false,
                "label": "Webhook credential",
                "help_text": "Personal Access Token for posting back the status to the service API",
                "filterable": true
            }
        }
    },

@costastf
Copy link
Collaborator

costastf commented Apr 29, 2021

Hi @mattschwen , thanks for the kind words! This library was created based on needs that have been covered. I am really happy that it is useful and I too wish it to be extended but I cannot currently put any time in it. MRs are more than welcome though and contribution will be properly acknowledged if you are willing to help. I can of course help you if you are interested in contributing.

@costastf
Copy link
Collaborator

Hi @mattschwen would you need any help with the above mentioned feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants