mirror of
https://github.com/ansible/awx.git
synced 2026-04-04 01:35:11 -02:30
Compare commits
20 Commits
feature-dj
...
feature_us
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05e9b29460 | ||
|
|
7f020052db | ||
|
|
53260213ba | ||
|
|
7d1ee37689 | ||
|
|
45c13c25a4 | ||
|
|
ba0e9831d2 | ||
|
|
92dce85468 | ||
|
|
77139e4138 | ||
|
|
b28e14c630 | ||
|
|
bf5594e338 | ||
|
|
f012a69c93 | ||
|
|
0fb334e372 | ||
|
|
b7c5cbac3f | ||
|
|
eb7407593f | ||
|
|
287596234c | ||
|
|
ee7b3470da | ||
|
|
0faa1c8a24 | ||
|
|
9d9f650051 | ||
|
|
4857685e1c | ||
|
|
8ba1a2bcf7 |
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -19,6 +19,8 @@ body:
|
||||
required: true
|
||||
- label: I understand that AWX is open source software provided for free and that I might not receive a timely response.
|
||||
required: true
|
||||
- label: I am **NOT** reporting a (potential) security vulnerability. (These should be emailed to `security@ansible.com` instead.)
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: summary
|
||||
|
||||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -3,7 +3,7 @@ name: CI
|
||||
env:
|
||||
LC_ALL: "C.UTF-8" # prevent ERROR: Ansible could not initialize the preferred locale: unsupported locale setting
|
||||
CI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
DEV_DOCKER_TAG_BASE: ghcr.io/${{ github.repository_owner }}
|
||||
DEV_DOCKER_OWNER: ${{ github.repository_owner }}
|
||||
COMPOSE_TAG: ${{ github.base_ref || 'devel' }}
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
5
Makefile
5
Makefile
@@ -42,7 +42,10 @@ TACACS ?= false
|
||||
|
||||
VENV_BASE ?= /var/lib/awx/venv
|
||||
|
||||
DEV_DOCKER_TAG_BASE ?= ghcr.io/ansible
|
||||
DEV_DOCKER_OWNER ?= ansible
|
||||
# Docker will only accept lowercase, so github names like Paul need to be paul
|
||||
DEV_DOCKER_OWNER_LOWER = $(shell echo $(DEV_DOCKER_OWNER) | tr A-Z a-z)
|
||||
DEV_DOCKER_TAG_BASE ?= ghcr.io/$(DEV_DOCKER_OWNER_LOWER)
|
||||
DEVEL_IMAGE_NAME ?= $(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG)
|
||||
|
||||
RECEPTOR_IMAGE ?= quay.io/ansible/receptor:devel
|
||||
|
||||
@@ -522,14 +522,16 @@ class SubListAPIView(ParentMixin, ListAPIView):
|
||||
def get_queryset(self):
|
||||
parent = self.get_parent_object()
|
||||
self.check_parent_access(parent)
|
||||
sublist_qs = self.get_sublist_queryset(parent)
|
||||
if not self.filter_read_permission:
|
||||
return optimize_queryset(sublist_qs)
|
||||
qs = self.request.user.get_queryset(self.model).distinct()
|
||||
return qs & sublist_qs
|
||||
return optimize_queryset(self.get_sublist_queryset(parent))
|
||||
qs = self.request.user.get_queryset(self.model)
|
||||
if hasattr(self, 'parent_key'):
|
||||
# This is vastly preferable for ReverseForeignKey relationships
|
||||
return qs.filter(**{self.parent_key: parent})
|
||||
return qs.distinct() & self.get_sublist_queryset(parent).distinct()
|
||||
|
||||
def get_sublist_queryset(self, parent):
|
||||
return getattrd(parent, self.relationship).distinct()
|
||||
return getattrd(parent, self.relationship)
|
||||
|
||||
|
||||
class DestroyAPIView(generics.DestroyAPIView):
|
||||
@@ -578,15 +580,6 @@ class SubListCreateAPIView(SubListAPIView, ListCreateAPIView):
|
||||
d.update({'parent_key': getattr(self, 'parent_key', None)})
|
||||
return d
|
||||
|
||||
def get_queryset(self):
|
||||
if hasattr(self, 'parent_key'):
|
||||
# Prefer this filtering because ForeignKey allows us more assumptions
|
||||
parent = self.get_parent_object()
|
||||
self.check_parent_access(parent)
|
||||
qs = self.request.user.get_queryset(self.model)
|
||||
return qs.filter(**{self.parent_key: parent})
|
||||
return super(SubListCreateAPIView, self).get_queryset()
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
# If the object ID was not specified, it probably doesn't exist in the
|
||||
# DB yet. We want to see if we can create it. The URL may choose to
|
||||
|
||||
@@ -284,7 +284,7 @@ class JobNotificationMixin(object):
|
||||
'workflow_url',
|
||||
'scm_branch',
|
||||
'artifacts',
|
||||
{'host_status_counts': ['skipped', 'ok', 'changed', 'failed', 'failures', 'dark' 'processed', 'rescued', 'ignored']},
|
||||
{'host_status_counts': ['skipped', 'ok', 'changed', 'failed', 'failures', 'dark', 'processed', 'rescued', 'ignored']},
|
||||
{
|
||||
'summary_fields': [
|
||||
{
|
||||
|
||||
@@ -639,7 +639,7 @@ class AWXReceptorJob:
|
||||
#
|
||||
RECEPTOR_CONFIG_STARTER = (
|
||||
{'local-only': None},
|
||||
{'log-level': 'debug'},
|
||||
{'log-level': 'info'},
|
||||
{'node': {'firewallrules': [{'action': 'reject', 'tonode': settings.CLUSTER_HOST_ID, 'toservice': 'control'}]}},
|
||||
{'control-service': {'service': 'control', 'filename': '/var/run/receptor/receptor.sock', 'permissions': '0660'}},
|
||||
{'work-command': {'worktype': 'local', 'command': 'ansible-runner', 'params': 'worker', 'allowruntimeparams': True}},
|
||||
|
||||
@@ -43,6 +43,7 @@ function LaunchButton({ resource, children }) {
|
||||
const [surveyConfig, setSurveyConfig] = useState(null);
|
||||
const [labels, setLabels] = useState([]);
|
||||
const [isLaunching, setIsLaunching] = useState(false);
|
||||
const [resourceCredentials, setResourceCredentials] = useState([]);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
const handleLaunch = async () => {
|
||||
@@ -83,6 +84,13 @@ function LaunchButton({ resource, children }) {
|
||||
setLabels(allLabels);
|
||||
}
|
||||
|
||||
if (launch.ask_credential_on_launch) {
|
||||
const {
|
||||
data: { results: templateCredentials },
|
||||
} = await JobTemplatesAPI.readCredentials(resource.id);
|
||||
setResourceCredentials(templateCredentials);
|
||||
}
|
||||
|
||||
if (canLaunchWithoutPrompt(launch)) {
|
||||
await launchWithParams({});
|
||||
} else {
|
||||
@@ -208,6 +216,7 @@ function LaunchButton({ resource, children }) {
|
||||
labels={labels}
|
||||
onLaunch={launchWithParams}
|
||||
onCancel={() => setShowLaunchPrompt(false)}
|
||||
resourceDefaultCredentials={resourceCredentials}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -47,6 +47,12 @@ describe('LaunchButton', () => {
|
||||
variables_needed_to_start: [],
|
||||
},
|
||||
});
|
||||
JobTemplatesAPI.readCredentials.mockResolvedValue({
|
||||
data: {
|
||||
count: 0,
|
||||
results: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => jest.clearAllMocks());
|
||||
|
||||
@@ -19,6 +19,7 @@ function PromptModalForm({
|
||||
labels,
|
||||
surveyConfig,
|
||||
instanceGroups,
|
||||
resourceDefaultCredentials,
|
||||
}) {
|
||||
const { setFieldTouched, values } = useFormikContext();
|
||||
const [showDescription, setShowDescription] = useState(false);
|
||||
@@ -35,9 +36,9 @@ function PromptModalForm({
|
||||
surveyConfig,
|
||||
resource,
|
||||
labels,
|
||||
instanceGroups
|
||||
instanceGroups,
|
||||
resourceDefaultCredentials
|
||||
);
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const postValues = {};
|
||||
const setValue = (key, value) => {
|
||||
|
||||
@@ -69,6 +69,20 @@ describe('LaunchPrompt', () => {
|
||||
spec: [{ type: 'text', variable: 'foo' }],
|
||||
},
|
||||
});
|
||||
JobTemplatesAPI.readCredentials.mockResolvedValue({
|
||||
data: {
|
||||
results: [
|
||||
{
|
||||
id: 5,
|
||||
name: 'cred that prompts',
|
||||
credential_type: 1,
|
||||
inputs: {
|
||||
password: 'ASK',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
InstanceGroupsAPI.read.mockResolvedValue({
|
||||
data: {
|
||||
results: [
|
||||
@@ -212,6 +226,16 @@ describe('LaunchPrompt', () => {
|
||||
],
|
||||
},
|
||||
}}
|
||||
resourceDefaultCredentials={[
|
||||
{
|
||||
id: 5,
|
||||
name: 'cred that prompts',
|
||||
credential_type: 1,
|
||||
inputs: {
|
||||
password: 'ASK',
|
||||
},
|
||||
},
|
||||
]}
|
||||
onLaunch={noop}
|
||||
onCancel={noop}
|
||||
surveyConfig={{
|
||||
@@ -289,6 +313,16 @@ describe('LaunchPrompt', () => {
|
||||
resource={resource}
|
||||
onLaunch={noop}
|
||||
onCancel={noop}
|
||||
resourceDefaultCredentials={[
|
||||
{
|
||||
id: 5,
|
||||
name: 'cred that prompts',
|
||||
credential_type: 1,
|
||||
inputs: {
|
||||
password: 'ASK',
|
||||
},
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'styled-components/macro';
|
||||
import React, { useState, useCallback, useEffect } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
|
||||
import { t } from '@lingui/macro';
|
||||
import { useField } from 'formik';
|
||||
@@ -8,7 +8,7 @@ import styled from 'styled-components';
|
||||
import { Alert, ToolbarItem } from '@patternfly/react-core';
|
||||
import { CredentialsAPI, CredentialTypesAPI } from 'api';
|
||||
import { getSearchableKeys } from 'components/PaginatedTable';
|
||||
import { getQSConfig, parseQueryString } from 'util/qs';
|
||||
import { getQSConfig, parseQueryString, updateQueryString } from 'util/qs';
|
||||
import useRequest from 'hooks/useRequest';
|
||||
import AnsibleSelect from '../../AnsibleSelect';
|
||||
import OptionsList from '../../OptionsList';
|
||||
@@ -31,18 +31,18 @@ function CredentialsStep({
|
||||
allowCredentialsWithPasswords,
|
||||
defaultCredentials = [],
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
const [field, meta, helpers] = useField({
|
||||
name: 'credentials',
|
||||
validate: (val) =>
|
||||
credentialsValidator(
|
||||
allowCredentialsWithPasswords,
|
||||
val,
|
||||
defaultCredentials
|
||||
defaultCredentials ?? []
|
||||
),
|
||||
});
|
||||
const [selectedType, setSelectedType] = useState(null);
|
||||
const history = useHistory();
|
||||
|
||||
const {
|
||||
result: types,
|
||||
error: typesError,
|
||||
@@ -104,12 +104,32 @@ function CredentialsStep({
|
||||
credentialsValidator(
|
||||
allowCredentialsWithPasswords,
|
||||
field.value,
|
||||
defaultCredentials
|
||||
defaultCredentials ?? []
|
||||
)
|
||||
);
|
||||
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
||||
}, []);
|
||||
|
||||
const removeAllSearchTerms = (qsConfig) => {
|
||||
const oldParams = parseQueryString(qsConfig, location.search);
|
||||
Object.keys(oldParams).forEach((key) => {
|
||||
oldParams[key] = null;
|
||||
});
|
||||
const defaultParams = {
|
||||
...oldParams,
|
||||
page: 1,
|
||||
page_size: 5,
|
||||
order_by: 'name',
|
||||
};
|
||||
const qs = updateQueryString(qsConfig, location.search, defaultParams);
|
||||
pushHistoryState(qs);
|
||||
};
|
||||
|
||||
const pushHistoryState = (qs) => {
|
||||
const { pathname } = history.location;
|
||||
history.push(qs ? `${pathname}?${qs}` : pathname);
|
||||
};
|
||||
|
||||
if (isTypesLoading) {
|
||||
return <ContentLoading />;
|
||||
}
|
||||
@@ -154,9 +174,7 @@ function CredentialsStep({
|
||||
value={selectedType && selectedType.id}
|
||||
onChange={(e, id) => {
|
||||
// Reset query params when the category of credentials is changed
|
||||
history.replace({
|
||||
search: '',
|
||||
});
|
||||
removeAllSearchTerms(QS_CONFIG);
|
||||
setSelectedType(types.find((o) => o.id === parseInt(id, 10)));
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -168,7 +168,9 @@ describe('CredentialsStep', () => {
|
||||
test('should reset query params (credential.page) when selected credential type is changed', async () => {
|
||||
let wrapper;
|
||||
const history = createMemoryHistory({
|
||||
initialEntries: ['?credential.page=2'],
|
||||
initialEntries: [
|
||||
'?credential.page=2&credential.page_size=5&credential.order_by=name',
|
||||
],
|
||||
});
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
|
||||
@@ -46,7 +46,8 @@ export default function useLaunchSteps(
|
||||
surveyConfig,
|
||||
resource,
|
||||
labels,
|
||||
instanceGroups
|
||||
instanceGroups,
|
||||
resourceDefaultCredentials
|
||||
) {
|
||||
const [visited, setVisited] = useState({});
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
@@ -56,7 +57,7 @@ export default function useLaunchSteps(
|
||||
useCredentialsStep(
|
||||
launchConfig,
|
||||
resource,
|
||||
resource.summary_fields.credentials || [],
|
||||
resourceDefaultCredentials,
|
||||
true
|
||||
),
|
||||
useCredentialPasswordsStep(
|
||||
|
||||
@@ -122,6 +122,18 @@ function sortWeekday(a, b) {
|
||||
}
|
||||
|
||||
function RunOnDetail({ type, options, prefix }) {
|
||||
const weekdays = {
|
||||
sunday: t`Sunday`,
|
||||
monday: t`Monday`,
|
||||
tuesday: t`Tuesday`,
|
||||
wednesday: t`Wednesday`,
|
||||
thursday: t`Thursday`,
|
||||
friday: t`Friday`,
|
||||
saturday: t`Saturday`,
|
||||
day: t`day`,
|
||||
weekday: t`weekday`,
|
||||
weekendDay: t`weekend day`,
|
||||
};
|
||||
if (type === 'month') {
|
||||
if (options.runOn === 'day') {
|
||||
return (
|
||||
@@ -132,16 +144,16 @@ function RunOnDetail({ type, options, prefix }) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
const dayOfWeek = options.runOnTheDay;
|
||||
const dayOfWeek = weekdays[options.runOnTheDay];
|
||||
return (
|
||||
<Detail
|
||||
label={t`Run on`}
|
||||
value={
|
||||
options.runOnDayNumber === -1 ? (
|
||||
options.runOnTheOccurrence === -1 ? (
|
||||
t`The last ${dayOfWeek}`
|
||||
) : (
|
||||
<SelectOrdinal
|
||||
value={options.runOnDayNumber}
|
||||
value={options.runOnTheOccurrence}
|
||||
one={`The first ${dayOfWeek}`}
|
||||
two={`The second ${dayOfWeek}`}
|
||||
_3={`The third ${dayOfWeek}`}
|
||||
@@ -178,18 +190,6 @@ function RunOnDetail({ type, options, prefix }) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
const weekdays = {
|
||||
sunday: t`Sunday`,
|
||||
monday: t`Monday`,
|
||||
tuesday: t`Tuesday`,
|
||||
wednesday: t`Wednesday`,
|
||||
thursday: t`Thursday`,
|
||||
friday: t`Friday`,
|
||||
saturday: t`Saturday`,
|
||||
day: t`day`,
|
||||
weekday: t`weekday`,
|
||||
weekendDay: t`weekend day`,
|
||||
};
|
||||
const weekday = weekdays[options.runOnTheDay];
|
||||
const month = months[options.runOnTheMonth];
|
||||
return (
|
||||
|
||||
@@ -11,7 +11,8 @@ import { JobTemplatesAPI, SchedulesAPI, WorkflowJobTemplatesAPI } from 'api';
|
||||
import { parseVariableField, jsonToYaml } from 'util/yaml';
|
||||
import { useConfig } from 'contexts/Config';
|
||||
import InstanceGroupLabels from 'components/InstanceGroupLabels';
|
||||
import parseRuleObj from '../shared/parseRuleObj';
|
||||
import parseRuleObj, { UnsupportedRRuleError } from '../shared/parseRuleObj';
|
||||
import UnsupportedRRuleAlert from '../shared/UnsupportedRRuleAlert';
|
||||
import FrequencyDetails from './FrequencyDetails';
|
||||
import AlertModal from '../../AlertModal';
|
||||
import { CardBody, CardActionsRow } from '../../Card';
|
||||
@@ -182,8 +183,20 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, surveyConfig }) {
|
||||
month: t`Month`,
|
||||
year: t`Year`,
|
||||
};
|
||||
const { frequency, frequencyOptions, exceptionFrequency, exceptionOptions } =
|
||||
parseRuleObj(schedule);
|
||||
let rruleError;
|
||||
let frequency = [];
|
||||
let frequencyOptions = {};
|
||||
let exceptionFrequency = [];
|
||||
let exceptionOptions = {};
|
||||
try {
|
||||
({ frequency, frequencyOptions, exceptionFrequency, exceptionOptions } =
|
||||
parseRuleObj(schedule));
|
||||
} catch (parseRuleError) {
|
||||
if (parseRuleError instanceof UnsupportedRRuleError) {
|
||||
rruleError = parseRuleError;
|
||||
}
|
||||
}
|
||||
|
||||
const repeatFrequency = frequency.length
|
||||
? frequency.map((f) => frequencies[f]).join(', ')
|
||||
: t`None (Run Once)`;
|
||||
@@ -602,6 +615,7 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, surveyConfig }) {
|
||||
</PromptDetailList>
|
||||
</>
|
||||
)}
|
||||
{rruleError && <UnsupportedRRuleAlert schedule={schedule} />}
|
||||
<CardActionsRow>
|
||||
{summary_fields?.user_capabilities?.edit && (
|
||||
<Button
|
||||
|
||||
@@ -587,4 +587,31 @@ describe('<ScheduleDetail />', () => {
|
||||
(el) => el.prop('isDisabled') === true
|
||||
);
|
||||
});
|
||||
test('should display warning for unsupported recurrence rules ', async () => {
|
||||
const unsupportedSchedule = {
|
||||
...schedule,
|
||||
rrule:
|
||||
'DTSTART:20221220T161500Z RRULE:FREQ=HOURLY;INTERVAL=1 EXRULE:FREQ=HOURLY;INTERVAL=1;BYDAY=TU;BYMONTHDAY=1,2,3,4,5,6,7 EXRULE:FREQ=HOURLY;INTERVAL=1;BYDAY=WE;BYMONTHDAY=2,3,4,5,6,7,8',
|
||||
};
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<Route
|
||||
path="/templates/job_template/:id/schedules/:scheduleId"
|
||||
component={() => <ScheduleDetail schedule={unsupportedSchedule} />}
|
||||
/>,
|
||||
{
|
||||
context: {
|
||||
router: {
|
||||
history,
|
||||
route: {
|
||||
location: history.location,
|
||||
match: { params: { id: 1 } },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
expect(wrapper.find('UnsupportedRRuleAlert').length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { t } from '@lingui/macro';
|
||||
import { Alert } from '@patternfly/react-core';
|
||||
|
||||
const AlertWrapper = styled.div`
|
||||
margin-top: var(--pf-global--spacer--lg);
|
||||
margin-bottom: var(--pf-global--spacer--lg);
|
||||
`;
|
||||
const RulesTitle = styled.p`
|
||||
margin-top: var(--pf-global--spacer--lg);
|
||||
margin-bottom: var(--pf-global--spacer--lg);
|
||||
font-weight: var(--pf-global--FontWeight--bold);
|
||||
`;
|
||||
|
||||
export default function UnsupportedRRuleAlert({ schedule }) {
|
||||
return (
|
||||
<AlertWrapper>
|
||||
<Alert
|
||||
isInline
|
||||
variant="danger"
|
||||
ouiaId="schedule-warning"
|
||||
title={t`This schedule uses complex rules that are not supported in the
|
||||
UI. Please use the API to manage this schedule.`}
|
||||
/>
|
||||
<RulesTitle>{t`Schedule Rules`}:</RulesTitle>
|
||||
<pre css="white-space: pre; font-family: var(--pf-global--FontFamily--monospace)">
|
||||
{schedule.rrule.split(' ').join('\n')}
|
||||
</pre>
|
||||
</AlertWrapper>
|
||||
);
|
||||
}
|
||||
@@ -82,11 +82,7 @@ const frequencyTypes = {
|
||||
};
|
||||
|
||||
function parseRrule(rruleString, schedule, values) {
|
||||
const { frequency, options } = parseRule(
|
||||
rruleString,
|
||||
schedule,
|
||||
values.exceptionFrequency
|
||||
);
|
||||
const { frequency, options } = parseRule(rruleString, schedule);
|
||||
|
||||
if (values.frequencyOptions[frequency]) {
|
||||
throw new UnsupportedRRuleError(
|
||||
@@ -105,11 +101,7 @@ function parseRrule(rruleString, schedule, values) {
|
||||
}
|
||||
|
||||
function parseExRule(exruleString, schedule, values) {
|
||||
const { frequency, options } = parseRule(
|
||||
exruleString,
|
||||
schedule,
|
||||
values.exceptionFrequency
|
||||
);
|
||||
const { frequency, options } = parseRule(exruleString, schedule);
|
||||
|
||||
if (values.exceptionOptions[frequency]) {
|
||||
throw new UnsupportedRRuleError(
|
||||
@@ -129,7 +121,7 @@ function parseExRule(exruleString, schedule, values) {
|
||||
};
|
||||
}
|
||||
|
||||
function parseRule(ruleString, schedule, frequencies) {
|
||||
function parseRule(ruleString, schedule) {
|
||||
const {
|
||||
origOptions: {
|
||||
bymonth,
|
||||
@@ -178,9 +170,6 @@ function parseRule(ruleString, schedule, frequencies) {
|
||||
throw new Error(`Unexpected rrule frequency: ${freq}`);
|
||||
}
|
||||
const frequency = frequencyTypes[freq];
|
||||
if (frequencies.includes(frequency)) {
|
||||
throw new Error(`Duplicate frequency types not supported (${frequency})`);
|
||||
}
|
||||
|
||||
if (freq === RRule.WEEKLY && byweekday) {
|
||||
options.daysOfWeek = byweekday;
|
||||
|
||||
@@ -91,6 +91,11 @@ function CredentialEdit({ credential }) {
|
||||
modifiedData.user = me.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (credential.kind === 'vault' && !credential.inputs?.vault_id) {
|
||||
delete modifiedData.inputs.vault_id;
|
||||
}
|
||||
|
||||
const [{ data }] = await Promise.all([
|
||||
CredentialsAPI.update(credId, modifiedData),
|
||||
...destroyInputSources(),
|
||||
@@ -100,7 +105,7 @@ function CredentialEdit({ credential }) {
|
||||
|
||||
return data;
|
||||
},
|
||||
[me, credId]
|
||||
[me, credId, credential]
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -47,35 +47,14 @@ class ItemNotDefined(Exception):
|
||||
class ControllerModule(AnsibleModule):
|
||||
url = None
|
||||
AUTH_ARGSPEC = dict(
|
||||
controller_host=dict(
|
||||
required=False,
|
||||
aliases=['tower_host'],
|
||||
fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST'])),
|
||||
controller_username=dict(
|
||||
required=False,
|
||||
aliases=['tower_username'],
|
||||
fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME'])),
|
||||
controller_password=dict(
|
||||
no_log=True,
|
||||
aliases=['tower_password'],
|
||||
required=False,
|
||||
fallback=(env_fallback, ['CONTROLLER_PASSWORD', 'TOWER_PASSWORD'])),
|
||||
validate_certs=dict(
|
||||
type='bool',
|
||||
aliases=['tower_verify_ssl'],
|
||||
required=False,
|
||||
fallback=(env_fallback, ['CONTROLLER_VERIFY_SSL', 'TOWER_VERIFY_SSL'])),
|
||||
controller_host=dict(required=False, aliases=['tower_host'], fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST'])),
|
||||
controller_username=dict(required=False, aliases=['tower_username'], fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME'])),
|
||||
controller_password=dict(no_log=True, aliases=['tower_password'], required=False, fallback=(env_fallback, ['CONTROLLER_PASSWORD', 'TOWER_PASSWORD'])),
|
||||
validate_certs=dict(type='bool', aliases=['tower_verify_ssl'], required=False, fallback=(env_fallback, ['CONTROLLER_VERIFY_SSL', 'TOWER_VERIFY_SSL'])),
|
||||
controller_oauthtoken=dict(
|
||||
type='raw',
|
||||
no_log=True,
|
||||
aliases=['tower_oauthtoken'],
|
||||
required=False,
|
||||
fallback=(env_fallback, ['CONTROLLER_OAUTH_TOKEN', 'TOWER_OAUTH_TOKEN'])),
|
||||
controller_config_file=dict(
|
||||
type='path',
|
||||
aliases=['tower_config_file'],
|
||||
required=False,
|
||||
default=None),
|
||||
type='raw', no_log=True, aliases=['tower_oauthtoken'], required=False, fallback=(env_fallback, ['CONTROLLER_OAUTH_TOKEN', 'TOWER_OAUTH_TOKEN'])
|
||||
),
|
||||
controller_config_file=dict(type='path', aliases=['tower_config_file'], required=False, default=None),
|
||||
)
|
||||
short_params = {
|
||||
'host': 'controller_host',
|
||||
@@ -320,9 +299,7 @@ class ControllerAPIModule(ControllerModule):
|
||||
def __init__(self, argument_spec, direct_params=None, error_callback=None, warn_callback=None, **kwargs):
|
||||
kwargs['supports_check_mode'] = True
|
||||
|
||||
super().__init__(
|
||||
argument_spec=argument_spec, direct_params=direct_params, error_callback=error_callback, warn_callback=warn_callback, **kwargs
|
||||
)
|
||||
super().__init__(argument_spec=argument_spec, direct_params=direct_params, error_callback=error_callback, warn_callback=warn_callback, **kwargs)
|
||||
self.session = Request(cookies=CookieJar(), validate_certs=self.verify_ssl)
|
||||
|
||||
if 'update_secrets' in self.params:
|
||||
@@ -330,11 +307,6 @@ class ControllerAPIModule(ControllerModule):
|
||||
else:
|
||||
self.update_secrets = True
|
||||
|
||||
@staticmethod
|
||||
def param_to_endpoint(name):
|
||||
exceptions = {'inventory': 'inventories', 'target_team': 'teams', 'workflow': 'workflow_job_templates'}
|
||||
return exceptions.get(name, '{0}s'.format(name))
|
||||
|
||||
@staticmethod
|
||||
def get_name_field_from_endpoint(endpoint):
|
||||
return ControllerAPIModule.IDENTITY_FIELDS.get(endpoint, 'name')
|
||||
@@ -405,7 +377,7 @@ class ControllerAPIModule(ControllerModule):
|
||||
response['json']['next'] = next_page
|
||||
return response
|
||||
|
||||
def get_one(self, endpoint, name_or_id=None, allow_none=True, **kwargs):
|
||||
def get_one(self, endpoint, name_or_id=None, allow_none=True, check_exists=False, **kwargs):
|
||||
new_kwargs = kwargs.copy()
|
||||
if name_or_id:
|
||||
name_field = self.get_name_field_from_endpoint(endpoint)
|
||||
@@ -446,6 +418,11 @@ class ControllerAPIModule(ControllerModule):
|
||||
# Or we weren't running with a or search and just got back too many to begin with.
|
||||
self.fail_wanted_one(response, endpoint, new_kwargs.get('data'))
|
||||
|
||||
if check_exists:
|
||||
name_field = self.get_name_field_from_endpoint(endpoint)
|
||||
self.json_output['id'] = response['json']['results'][0]['id']
|
||||
self.exit_json(**self.json_output)
|
||||
|
||||
return response['json']['results'][0]
|
||||
|
||||
def fail_wanted_one(self, response, endpoint, query_params):
|
||||
@@ -453,7 +430,8 @@ class ControllerAPIModule(ControllerModule):
|
||||
if len(sample['json']['results']) > 1:
|
||||
sample['json']['results'] = sample['json']['results'][:2] + ['...more results snipped...']
|
||||
url = self.build_url(endpoint, query_params)
|
||||
display_endpoint = url.geturl()[len(self.host):] # truncate to not include the base URL
|
||||
host_length = len(self.host)
|
||||
display_endpoint = url.geturl()[host_length:] # truncate to not include the base URL
|
||||
self.fail_json(
|
||||
msg="Request to {0} returned {1} items, expected 1".format(display_endpoint, response['json']['count']),
|
||||
query=query_params,
|
||||
@@ -975,11 +953,7 @@ class ControllerAPIModule(ControllerModule):
|
||||
# Attempt to delete our current token from /api/v2/tokens/
|
||||
# Post to the tokens endpoint with baisc auth to try and get a token
|
||||
endpoint = self.url_prefix.rstrip('/') + '/api/v2/tokens/{0}/'.format(self.oauth_token_id)
|
||||
api_token_url = (
|
||||
self.url._replace(
|
||||
path=endpoint, query=None # in error cases, fail_json exists before exception handling
|
||||
)
|
||||
).geturl()
|
||||
api_token_url = (self.url._replace(path=endpoint, query=None)).geturl() # in error cases, fail_json exists before exception handling
|
||||
|
||||
try:
|
||||
self.session.open(
|
||||
|
||||
@@ -60,7 +60,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
skip_authorization:
|
||||
description:
|
||||
@@ -106,7 +106,7 @@ def main():
|
||||
client_type=dict(choices=['public', 'confidential']),
|
||||
organization=dict(required=True),
|
||||
redirect_uris=dict(type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
skip_authorization=dict(type='bool'),
|
||||
)
|
||||
|
||||
@@ -127,7 +127,7 @@ def main():
|
||||
org_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up application based on the provided name and org ID
|
||||
application = module.get_one('applications', name_or_id=name, **{'data': {'organization': org_id}})
|
||||
application = module.get_one('applications', name_or_id=name, check_exists=(state == 'exists'), **{'data': {'organization': org_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -247,7 +247,7 @@ def main():
|
||||
if organization:
|
||||
lookup_data['organization'] = org_id
|
||||
|
||||
credential = module.get_one('credentials', name_or_id=name, **{'data': lookup_data})
|
||||
credential = module.get_one('credentials', name_or_id=name, check_exists=(state == 'exists'), **{'data': lookup_data})
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
@@ -265,10 +265,6 @@ def main():
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
module.delete_if_needed(credential)
|
||||
|
||||
if state == 'exists' and credential is not None:
|
||||
# If credential exists and state is exists, we're done here.
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
# Attempt to look up the related items the user specified (these will fail the module if not found)
|
||||
if user:
|
||||
user_id = module.resolve_name_to_id('users', user)
|
||||
|
||||
@@ -48,7 +48,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
|
||||
@@ -80,7 +80,7 @@ def main():
|
||||
target_credential=dict(required=True),
|
||||
source_credential=dict(),
|
||||
metadata=dict(type="dict"),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -101,7 +101,7 @@ def main():
|
||||
'target_credential': target_credential_id,
|
||||
'input_field_name': input_field_name,
|
||||
}
|
||||
credential_input_source = module.get_one('credential_input_sources', **{'data': lookup_data})
|
||||
credential_input_source = module.get_one('credential_input_sources', check_exists=(state == 'exists'), **{'data': lookup_data})
|
||||
|
||||
if state == 'absent':
|
||||
module.delete_if_needed(credential_input_source)
|
||||
|
||||
@@ -59,7 +59,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
@@ -98,7 +98,7 @@ def main():
|
||||
kind=dict(choices=list(KIND_CHOICES.keys())),
|
||||
inputs=dict(type='dict'),
|
||||
injectors=dict(type='dict'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -124,7 +124,7 @@ def main():
|
||||
credential_type_params['injectors'] = module.params.get('injectors')
|
||||
|
||||
# Attempt to look up credential_type based on the provided name
|
||||
credential_type = module.get_one('credential_types', name_or_id=name)
|
||||
credential_type = module.get_one('credential_types', name_or_id=name, check_exists=(state == 'exists'))
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -50,7 +50,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
pull:
|
||||
@@ -83,7 +83,7 @@ def main():
|
||||
description=dict(),
|
||||
organization=dict(),
|
||||
credential=dict(),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
# NOTE: Default for pull differs from API (which is blank by default)
|
||||
pull=dict(choices=['always', 'missing', 'never'], default='missing'),
|
||||
)
|
||||
@@ -99,7 +99,7 @@ def main():
|
||||
state = module.params.get('state')
|
||||
pull = module.params.get('pull')
|
||||
|
||||
existing_item = module.get_one('execution_environments', name_or_id=name)
|
||||
existing_item = module.get_one('execution_environments', name_or_id=name, check_exists=(state == 'exists'))
|
||||
|
||||
if state == 'absent':
|
||||
module.delete_if_needed(existing_item)
|
||||
|
||||
@@ -67,7 +67,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
new_name:
|
||||
description:
|
||||
@@ -115,7 +115,7 @@ def main():
|
||||
children=dict(type='list', elements='str', aliases=['groups']),
|
||||
preserve_existing_hosts=dict(type='bool', default=False),
|
||||
preserve_existing_children=dict(type='bool', default=False, aliases=['preserve_existing_groups']),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -135,7 +135,7 @@ def main():
|
||||
inventory_id = module.resolve_name_to_id('inventories', inventory)
|
||||
|
||||
# Attempt to look up the object based on the provided name and inventory ID
|
||||
group = module.get_one('groups', name_or_id=name, **{'data': {'inventory': inventory_id}})
|
||||
group = module.get_one('groups', name_or_id=name, check_exists=(state == 'exists'), **{'data': {'inventory': inventory_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -50,7 +50,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
@@ -83,7 +83,7 @@ def main():
|
||||
inventory=dict(required=True),
|
||||
enabled=dict(type='bool'),
|
||||
variables=dict(type='dict'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -102,7 +102,7 @@ def main():
|
||||
inventory_id = module.resolve_name_to_id('inventories', inventory)
|
||||
|
||||
# Attempt to look up host based on the provided name and inventory ID
|
||||
host = module.get_one('hosts', name_or_id=name, **{'data': {'inventory': inventory_id}})
|
||||
host = module.get_one('hosts', name_or_id=name, check_exists=(state == 'exists'), **{'data': {'inventory': inventory_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -81,7 +81,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
@@ -107,7 +107,7 @@ def main():
|
||||
policy_instance_list=dict(type='list', elements='str'),
|
||||
pod_spec_override=dict(),
|
||||
instances=dict(required=False, type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -128,7 +128,7 @@ def main():
|
||||
state = module.params.get('state')
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('instance_groups', name_or_id=name)
|
||||
existing_item = module.get_one('instance_groups', name_or_id=name, check_exists=(state == 'exists'))
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -78,7 +78,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
@@ -149,7 +149,7 @@ def main():
|
||||
host_filter=dict(),
|
||||
instance_groups=dict(type="list", elements='str'),
|
||||
prevent_instance_group_fallback=dict(type='bool'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
input_inventories=dict(type='list', elements='str'),
|
||||
)
|
||||
|
||||
@@ -172,7 +172,7 @@ def main():
|
||||
org_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up inventory based on the provided name and org ID
|
||||
inventory = module.get_one('inventories', name_or_id=name, **{'data': {'organization': org_id}})
|
||||
inventory = module.get_one('inventories', name_or_id=name, check_exists=(state == 'exists'), **{'data': {'organization': org_id}})
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
|
||||
@@ -118,7 +118,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
notification_templates_started:
|
||||
description:
|
||||
@@ -192,7 +192,7 @@ def main():
|
||||
notification_templates_started=dict(type="list", elements='str'),
|
||||
notification_templates_success=dict(type="list", elements='str'),
|
||||
notification_templates_error=dict(type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -219,6 +219,7 @@ def main():
|
||||
inventory_source_object = module.get_one(
|
||||
'inventory_sources',
|
||||
name_or_id=name,
|
||||
check_exists=(state == 'exists'),
|
||||
**{
|
||||
'data': {
|
||||
'inventory': inventory_object['id'],
|
||||
|
||||
@@ -295,7 +295,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
notification_templates_started:
|
||||
description:
|
||||
@@ -444,7 +444,7 @@ def main():
|
||||
notification_templates_success=dict(type="list", elements='str'),
|
||||
notification_templates_error=dict(type="list", elements='str'),
|
||||
prevent_instance_group_fallback=dict(type="bool"),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -484,7 +484,7 @@ def main():
|
||||
new_fields['execution_environment'] = module.resolve_name_to_id('execution_environments', ee)
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('job_templates', name_or_id=name, **{'data': search_fields})
|
||||
existing_item = module.get_one('job_templates', name_or_id=name, check_exists=(state == 'exists'), **{'data': search_fields})
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
|
||||
@@ -41,7 +41,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present"]
|
||||
choices: ["present", "exists"]
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
@@ -62,7 +62,7 @@ def main():
|
||||
name=dict(required=True),
|
||||
new_name=dict(),
|
||||
organization=dict(required=True),
|
||||
state=dict(choices=['present'], default='present'),
|
||||
state=dict(choices=['present', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -72,6 +72,7 @@ def main():
|
||||
name = module.params.get('name')
|
||||
new_name = module.params.get("new_name")
|
||||
organization = module.params.get('organization')
|
||||
state = module.params.get("state")
|
||||
|
||||
# Attempt to look up the related items the user specified (these will fail the module if not found)
|
||||
organization_id = None
|
||||
@@ -82,6 +83,7 @@ def main():
|
||||
existing_item = module.get_one(
|
||||
'labels',
|
||||
name_or_id=name,
|
||||
check_exists=(state == 'exists'),
|
||||
**{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
|
||||
@@ -97,7 +97,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
@@ -222,7 +222,7 @@ def main():
|
||||
notification_type=dict(choices=['email', 'grafana', 'irc', 'mattermost', 'pagerduty', 'rocketchat', 'slack', 'twilio', 'webhook']),
|
||||
notification_configuration=dict(type='dict'),
|
||||
messages=dict(type='dict'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -248,6 +248,7 @@ def main():
|
||||
existing_item = module.get_one(
|
||||
'notification_templates',
|
||||
name_or_id=name,
|
||||
check_exists=(state == 'exists'),
|
||||
**{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
|
||||
@@ -52,7 +52,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
instance_groups:
|
||||
description:
|
||||
@@ -130,7 +130,7 @@ def main():
|
||||
notification_templates_error=dict(type="list", elements='str'),
|
||||
notification_templates_approvals=dict(type="list", elements='str'),
|
||||
galaxy_credentials=dict(type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -146,7 +146,7 @@ def main():
|
||||
state = module.params.get('state')
|
||||
|
||||
# Attempt to look up organization based on the provided name
|
||||
organization = module.get_one('organizations', name_or_id=name)
|
||||
organization = module.get_one('organizations', name_or_id=name, check_exists=(state == 'exists'))
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -122,7 +122,7 @@ options:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
type: str
|
||||
wait:
|
||||
description:
|
||||
@@ -272,7 +272,7 @@ def main():
|
||||
notification_templates_started=dict(type="list", elements='str'),
|
||||
notification_templates_success=dict(type="list", elements='str'),
|
||||
notification_templates_error=dict(type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
wait=dict(type='bool', default=True),
|
||||
update_project=dict(default=False, type='bool'),
|
||||
interval=dict(default=2.0, type='float'),
|
||||
@@ -313,7 +313,7 @@ def main():
|
||||
lookup_data['organization'] = org_id
|
||||
|
||||
# Attempt to look up project based on the provided name and org ID
|
||||
project = module.get_one('projects', name_or_id=name, data=lookup_data)
|
||||
project = module.get_one('projects', name_or_id=name, check_exists=(state == 'exists'), data=lookup_data)
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
|
||||
@@ -24,11 +24,23 @@ options:
|
||||
user:
|
||||
description:
|
||||
- User that receives the permissions specified by the role.
|
||||
- Deprecated, use 'users'.
|
||||
type: str
|
||||
users:
|
||||
description:
|
||||
- Users that receive the permissions specified by the role.
|
||||
type: list
|
||||
elements: str
|
||||
team:
|
||||
description:
|
||||
- Team that receives the permissions specified by the role.
|
||||
- Deprecated, use 'teams'.
|
||||
type: str
|
||||
teams:
|
||||
description:
|
||||
- Teams that receive the permissions specified by the role.
|
||||
type: list
|
||||
elements: str
|
||||
role:
|
||||
description:
|
||||
- The role type to grant/revoke.
|
||||
@@ -161,7 +173,9 @@ def main():
|
||||
|
||||
argument_spec = dict(
|
||||
user=dict(),
|
||||
users=dict(type='list', elements='str'),
|
||||
team=dict(),
|
||||
teams=dict(type='list', elements='str'),
|
||||
role=dict(
|
||||
choices=[
|
||||
"admin",
|
||||
@@ -219,9 +233,9 @@ def main():
|
||||
'projects': 'project',
|
||||
'target_teams': 'target_team',
|
||||
'workflows': 'workflow',
|
||||
'users': 'user',
|
||||
'teams': 'team',
|
||||
}
|
||||
# Singular parameters
|
||||
resource_param_keys = ('user', 'team', 'lookup_organization')
|
||||
|
||||
resources = {}
|
||||
for resource_group, old_name in resource_list_param_keys.items():
|
||||
@@ -229,9 +243,9 @@ def main():
|
||||
resources.setdefault(resource_group, []).extend(module.params.get(resource_group))
|
||||
if module.params.get(old_name) is not None:
|
||||
resources.setdefault(resource_group, []).append(module.params.get(old_name))
|
||||
for resource_group in resource_param_keys:
|
||||
if module.params.get(resource_group) is not None:
|
||||
resources[resource_group] = module.params.get(resource_group)
|
||||
if module.params.get('lookup_organization') is not None:
|
||||
resources['lookup_organization'] = module.params.get('lookup_organization')
|
||||
|
||||
# Change workflows and target_teams key to its endpoint name.
|
||||
if 'workflows' in resources:
|
||||
resources['workflow_job_templates'] = resources.pop('workflows')
|
||||
@@ -248,28 +262,13 @@ def main():
|
||||
# separate actors from resources
|
||||
actor_data = {}
|
||||
missing_items = []
|
||||
for key in ('user', 'team'):
|
||||
if key in resources:
|
||||
if key == 'user':
|
||||
lookup_data_populated = {}
|
||||
else:
|
||||
lookup_data_populated = lookup_data
|
||||
# Attempt to look up project based on the provided name or ID and lookup data
|
||||
data = module.get_one('{0}s'.format(key), name_or_id=resources[key], data=lookup_data_populated)
|
||||
if data is None:
|
||||
module.fail_json(
|
||||
msg='Unable to find {0} with name: {1}'.format(key, resources[key]), changed=False
|
||||
)
|
||||
else:
|
||||
actor_data[key] = module.get_one('{0}s'.format(key), name_or_id=resources[key], data=lookup_data_populated)
|
||||
resources.pop(key)
|
||||
# Lookup Resources
|
||||
resource_data = {}
|
||||
for key, value in resources.items():
|
||||
for resource in value:
|
||||
# Attempt to look up project based on the provided name or ID and lookup data
|
||||
if key in resources:
|
||||
if key == 'organizations':
|
||||
if key == 'organizations' or key == 'users':
|
||||
lookup_data_populated = {}
|
||||
else:
|
||||
lookup_data_populated = lookup_data
|
||||
@@ -277,14 +276,18 @@ def main():
|
||||
if data is None:
|
||||
missing_items.append(resource)
|
||||
else:
|
||||
resource_data.setdefault(key, []).append(data)
|
||||
if key == 'users' or key == 'teams':
|
||||
actor_data.setdefault(key, []).append(data)
|
||||
else:
|
||||
resource_data.setdefault(key, []).append(data)
|
||||
if len(missing_items) > 0:
|
||||
module.fail_json(
|
||||
msg='There were {0} missing items, missing items: {1}'.format(len(missing_items), missing_items), changed=False
|
||||
)
|
||||
|
||||
# build association agenda
|
||||
associations = {}
|
||||
for actor_type, actor in actor_data.items():
|
||||
for actor_type, actors in actor_data.items():
|
||||
for key, value in resource_data.items():
|
||||
for resource in value:
|
||||
resource_roles = resource['summary_fields']['object_roles']
|
||||
@@ -294,9 +297,10 @@ def main():
|
||||
msg='Resource {0} has no role {1}, available roles: {2}'.format(resource['url'], role_field, available_roles), changed=False
|
||||
)
|
||||
role_data = resource_roles[role_field]
|
||||
endpoint = '/roles/{0}/{1}/'.format(role_data['id'], module.param_to_endpoint(actor_type))
|
||||
endpoint = '/roles/{0}/{1}/'.format(role_data['id'], actor_type)
|
||||
associations.setdefault(endpoint, [])
|
||||
associations[endpoint].append(actor['id'])
|
||||
for actor in actors:
|
||||
associations[endpoint].append(actor['id'])
|
||||
|
||||
# perform associations
|
||||
for association_endpoint, new_association_list in associations.items():
|
||||
|
||||
@@ -146,7 +146,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
@@ -220,7 +220,7 @@ def main():
|
||||
unified_job_template=dict(),
|
||||
organization=dict(),
|
||||
enabled=dict(type='bool'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -265,8 +265,13 @@ def main():
|
||||
search_fields['name'] = unified_job_template
|
||||
unified_job_template_id = module.get_one('unified_job_templates', **{'data': search_fields})['id']
|
||||
sched_search_fields['unified_job_template'] = unified_job_template_id
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('schedules', name_or_id=name, **{'data': sched_search_fields})
|
||||
existing_item = module.get_one('schedules', name_or_id=name, check_exists=(state == 'exists'), **{'data': sched_search_fields})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
module.delete_if_needed(existing_item)
|
||||
|
||||
association_fields = {}
|
||||
|
||||
@@ -343,18 +348,14 @@ def main():
|
||||
else:
|
||||
new_fields['execution_environment'] = ee['id']
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
module.delete_if_needed(existing_item)
|
||||
elif state == 'present':
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item,
|
||||
new_fields,
|
||||
endpoint='schedules',
|
||||
item_type='schedule',
|
||||
associations=association_fields,
|
||||
)
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item,
|
||||
new_fields,
|
||||
endpoint='schedules',
|
||||
item_type='schedule',
|
||||
associations=association_fields,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -42,7 +42,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
@@ -69,7 +69,7 @@ def main():
|
||||
new_name=dict(),
|
||||
description=dict(),
|
||||
organization=dict(required=True),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -86,7 +86,7 @@ def main():
|
||||
org_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up team based on the provided name and org ID
|
||||
team = module.get_one('teams', name_or_id=name, **{'data': {'organization': org_id}})
|
||||
team = module.get_one('teams', name_or_id=name, check_exists=(state == 'exists'), **{'data': {'organization': org_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -69,7 +69,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
@@ -137,7 +137,7 @@ def main():
|
||||
password=dict(no_log=True),
|
||||
update_secrets=dict(type='bool', default=True, no_log=False),
|
||||
organization=dict(),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -158,7 +158,7 @@ def main():
|
||||
# Attempt to look up the related items the user specified (these will fail the module if not found)
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('users', name_or_id=username)
|
||||
existing_item = module.get_one('users', name_or_id=username, check_exists=(state == 'exists'))
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -144,6 +144,7 @@ options:
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
- exists
|
||||
default: "present"
|
||||
type: str
|
||||
notification_templates_started:
|
||||
@@ -667,8 +668,7 @@ def create_workflow_nodes(module, response, workflow_nodes, workflow_id):
|
||||
inv_lookup_data = {}
|
||||
if 'organization' in workflow_node['inventory']:
|
||||
inv_lookup_data['organization'] = module.resolve_name_to_id('organizations', workflow_node['inventory']['organization']['name'])
|
||||
workflow_node_fields['inventory'] = module.get_one(
|
||||
'inventories', name_or_id=workflow_node['inventory']['name'], data=inv_lookup_data)['id']
|
||||
workflow_node_fields['inventory'] = module.get_one('inventories', name_or_id=workflow_node['inventory']['name'], data=inv_lookup_data)['id']
|
||||
else:
|
||||
workflow_node_fields['inventory'] = module.get_one('inventories', name_or_id=workflow_node['inventory'])['id']
|
||||
|
||||
@@ -843,7 +843,7 @@ def main():
|
||||
notification_templates_approvals=dict(type="list", elements='str'),
|
||||
workflow_nodes=dict(type='list', elements='dict', aliases=['schema']),
|
||||
destroy_current_nodes=dict(type='bool', default=False, aliases=['destroy_current_schema']),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -871,7 +871,7 @@ def main():
|
||||
search_fields['organization'] = new_fields['organization'] = organization_id
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('workflow_job_templates', name_or_id=name, **{'data': search_fields})
|
||||
existing_item = module.get_one('workflow_job_templates', name_or_id=name, check_exists=(state == 'exists'), **{'data': search_fields})
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
|
||||
@@ -179,7 +179,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
@@ -285,7 +285,7 @@ def main():
|
||||
job_slice_count=dict(type='int'),
|
||||
labels=dict(type='list', elements='str'),
|
||||
timeout=dict(type='int'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
)
|
||||
mutually_exclusive = [("unified_job_template", "approval_node")]
|
||||
required_if = [
|
||||
@@ -327,7 +327,7 @@ def main():
|
||||
search_fields['workflow_job_template'] = new_fields['workflow_job_template'] = workflow_job_template_id
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('workflow_job_template_nodes', **{'data': search_fields})
|
||||
existing_item = module.get_one('workflow_job_template_nodes', check_exists=(state == 'exists'), **{'data': search_fields})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -24,6 +24,43 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Run an application with exists
|
||||
application:
|
||||
name: "{{ app1_name }}"
|
||||
authorization_grant_type: "password"
|
||||
client_type: "public"
|
||||
organization: "Default"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete our application
|
||||
application:
|
||||
name: "{{ app1_name }}"
|
||||
organization: "Default"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Run an application with exists
|
||||
application:
|
||||
name: "{{ app1_name }}"
|
||||
authorization_grant_type: "password"
|
||||
client_type: "public"
|
||||
organization: "Default"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete our application
|
||||
application:
|
||||
name: "{{ app1_name }}"
|
||||
|
||||
@@ -47,6 +47,42 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an Org-specific credential with an ID with exists
|
||||
credential:
|
||||
name: "{{ ssh_cred_name1 }}"
|
||||
organization: Default
|
||||
credential_type: Machine
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete an Org-specific credential with an ID
|
||||
credential:
|
||||
name: "{{ ssh_cred_name1 }}"
|
||||
organization: Default
|
||||
credential_type: Machine
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an Org-specific credential with an ID with exists
|
||||
credential:
|
||||
name: "{{ ssh_cred_name1 }}"
|
||||
organization: Default
|
||||
credential_type: Machine
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete a Org-specific credential
|
||||
credential:
|
||||
name: "{{ ssh_cred_name1 }}"
|
||||
|
||||
@@ -54,6 +54,51 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add credential Input Source with exists
|
||||
credential_input_source:
|
||||
input_field_name: password
|
||||
target_credential: "{{ target_cred_result.id }}"
|
||||
source_credential: "{{ src_cred_result.id }}"
|
||||
metadata:
|
||||
object_query: "Safe=MY_SAFE;Object=AWX-user"
|
||||
object_query_format: "Exact"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete credential Input Source
|
||||
credential_input_source:
|
||||
input_field_name: password
|
||||
target_credential: "{{ target_cred_result.id }}"
|
||||
source_credential: "{{ src_cred_result.id }}"
|
||||
metadata:
|
||||
object_query: "Safe=MY_SAFE;Object=AWX-user"
|
||||
object_query_format: "Exact"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add credential Input Source with exists
|
||||
credential_input_source:
|
||||
input_field_name: password
|
||||
target_credential: "{{ target_cred_result.id }}"
|
||||
source_credential: "{{ src_cred_result.id }}"
|
||||
metadata:
|
||||
object_query: "Safe=MY_SAFE;Object=AWX-user"
|
||||
object_query_format: "Exact"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add Second credential Lookup
|
||||
credential:
|
||||
description: Credential for Testing Source Change
|
||||
|
||||
@@ -22,6 +22,48 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add Tower credential type with exists
|
||||
credential_type:
|
||||
description: Credential type for Test
|
||||
name: "{{ cred_type_name }}"
|
||||
kind: cloud
|
||||
inputs: {"fields": [{"type": "string", "id": "username", "label": "Username"}, {"secret": true, "type": "string", "id": "password", "label": "Password"}], "required": ["username", "password"]}
|
||||
injectors: {"extra_vars": {"test": "foo"}}
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete the credential type
|
||||
credential_type:
|
||||
description: Credential type for Test
|
||||
name: "{{ cred_type_name }}"
|
||||
kind: cloud
|
||||
inputs: {"fields": [{"type": "string", "id": "username", "label": "Username"}, {"secret": true, "type": "string", "id": "password", "label": "Password"}], "required": ["username", "password"]}
|
||||
injectors: {"extra_vars": {"test": "foo"}}
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add Tower credential type with exists
|
||||
credential_type:
|
||||
description: Credential type for Test
|
||||
name: "{{ cred_type_name }}"
|
||||
kind: cloud
|
||||
inputs: {"fields": [{"type": "string", "id": "username", "label": "Username"}, {"secret": true, "type": "string", "id": "password", "label": "Password"}], "required": ["username", "password"]}
|
||||
injectors: {"extra_vars": {"test": "foo"}}
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Rename Tower credential type
|
||||
credential_type:
|
||||
name: "{{ cred_type_name }}"
|
||||
|
||||
@@ -22,6 +22,48 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add an EE with exists
|
||||
execution_environment:
|
||||
name: "{{ ee_name }}"
|
||||
description: "EE for Testing"
|
||||
image: quay.io/ansible/awx-ee
|
||||
pull: always
|
||||
organization: Default
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete an EE
|
||||
execution_environment:
|
||||
name: "{{ ee_name }}"
|
||||
description: "EE for Testing"
|
||||
image: quay.io/ansible/awx-ee
|
||||
pull: always
|
||||
organization: Default
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add an EE with exists
|
||||
execution_environment:
|
||||
name: "{{ ee_name }}"
|
||||
description: "EE for Testing"
|
||||
image: quay.io/ansible/awx-ee
|
||||
pull: always
|
||||
organization: Default
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Associate the Test EE with Default Org (this should fail)
|
||||
execution_environment:
|
||||
name: "{{ ee_name }}"
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
name: "{{ inv_name }}"
|
||||
organization: Default
|
||||
state: present
|
||||
register: result
|
||||
registuer: result
|
||||
|
||||
- name: Create a Group
|
||||
- name: Create Group 1
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ result.id }}"
|
||||
@@ -34,7 +34,46 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a Group
|
||||
- name: Create Group 1 with exists
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: exists
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete Group 1
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: absent
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create Group 1 with exists
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: exists
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create Group 2
|
||||
group:
|
||||
name: "{{ group_name2 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
@@ -47,7 +86,7 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a Group
|
||||
- name: Create Group 3
|
||||
group:
|
||||
name: "{{ group_name3 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
@@ -69,7 +108,7 @@
|
||||
- "{{ host_name2 }}"
|
||||
- "{{ host_name3 }}"
|
||||
|
||||
- name: Create a Group with hosts and sub group
|
||||
- name: Create Group 1 with hosts and sub group of Group 2
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
@@ -83,7 +122,7 @@
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- name: Create a Group with hosts and sub group
|
||||
- name: Create Group 1 with hosts and sub group
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
@@ -104,18 +143,7 @@
|
||||
that:
|
||||
- group1_host_count == "3"
|
||||
|
||||
- name: Delete a Group
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete a Group
|
||||
- name: Delete Group 2
|
||||
group:
|
||||
name: "{{ group_name2 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
@@ -127,7 +155,7 @@
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete a Group
|
||||
- name: Delete Group 3
|
||||
group:
|
||||
name: "{{ group_name3 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
@@ -136,7 +164,19 @@
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
- "result is changed"
|
||||
|
||||
# If we delete group 1 first it will delete group 2 and 3
|
||||
- name: Delete Group 1
|
||||
group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
group:
|
||||
|
||||
@@ -29,6 +29,45 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a Host with exists
|
||||
host:
|
||||
name: "{{ host_name }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: exists
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete a Host
|
||||
host:
|
||||
name: "{{ host_name }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: absent
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a Host with exists
|
||||
host:
|
||||
name: "{{ host_name }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: exists
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete a Host
|
||||
host:
|
||||
name: "{{ result.id }}"
|
||||
|
||||
@@ -38,6 +38,42 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an Instance Group with exists
|
||||
instance_group:
|
||||
name: "{{ group_name1 }}"
|
||||
policy_instance_percentage: 34
|
||||
policy_instance_minimum: 12
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete an Instance Group
|
||||
instance_group:
|
||||
name: "{{ group_name1 }}"
|
||||
policy_instance_percentage: 34
|
||||
policy_instance_minimum: 12
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an Instance Group with exists
|
||||
instance_group:
|
||||
name: "{{ group_name1 }}"
|
||||
policy_instance_percentage: 34
|
||||
policy_instance_minimum: 12
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Update an Instance Group
|
||||
instance_group:
|
||||
name: "{{ result.id }}"
|
||||
|
||||
@@ -51,6 +51,45 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an Inventory with exists
|
||||
inventory:
|
||||
name: "{{ inv_name1 }}"
|
||||
organization: Default
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete an Inventory
|
||||
inventory:
|
||||
name: "{{ inv_name1 }}"
|
||||
organization: Default
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an Inventory with exists
|
||||
inventory:
|
||||
name: "{{ inv_name1 }}"
|
||||
organization: Default
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Test Inventory module idempotency
|
||||
inventory:
|
||||
name: "{{ result.id }}"
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
organization: Default
|
||||
name: "{{ openstack_inv }}"
|
||||
|
||||
- name: Create a source inventory
|
||||
- name: Create an source inventory
|
||||
inventory_source:
|
||||
name: "{{ openstack_inv_source }}"
|
||||
description: Source for Test inventory
|
||||
@@ -47,6 +47,60 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an source inventory with exists
|
||||
inventory_source:
|
||||
name: "{{ openstack_inv_source }}"
|
||||
description: Source for Test inventory
|
||||
inventory: "{{ openstack_inv }}"
|
||||
credential: "{{ credential_result.id }}"
|
||||
overwrite: true
|
||||
update_on_launch: true
|
||||
source_vars:
|
||||
private: false
|
||||
source: openstack
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete an source inventory
|
||||
inventory_source:
|
||||
name: "{{ openstack_inv_source }}"
|
||||
description: Source for Test inventory
|
||||
inventory: "{{ openstack_inv }}"
|
||||
credential: "{{ credential_result.id }}"
|
||||
overwrite: true
|
||||
update_on_launch: true
|
||||
source_vars:
|
||||
private: false
|
||||
source: openstack
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create an source inventory with exists
|
||||
inventory_source:
|
||||
name: "{{ openstack_inv_source }}"
|
||||
description: Source for Test inventory
|
||||
inventory: "{{ openstack_inv }}"
|
||||
credential: "{{ credential_result.id }}"
|
||||
overwrite: true
|
||||
update_on_launch: true
|
||||
source_vars:
|
||||
private: false
|
||||
source: openstack
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete the inventory source with an invalid cred and source_project specified
|
||||
inventory_source:
|
||||
name: "{{ result.id }}"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
cred1: "AWX-Collection-tests-job_template-cred1-{{ test_id }}"
|
||||
cred2: "AWX-Collection-tests-job_template-cred2-{{ test_id }}"
|
||||
cred3: "AWX-Collection-tests-job_template-cred3-{{ test_id }}"
|
||||
inv1: "AWX-Collection-tests-job_template-inv-{{ test_id }}"
|
||||
proj1: "AWX-Collection-tests-job_template-proj-{{ test_id }}"
|
||||
jt1: "AWX-Collection-tests-job_template-jt1-{{ test_id }}"
|
||||
jt2: "AWX-Collection-tests-job_template-jt2-{{ test_id }}"
|
||||
@@ -25,6 +26,11 @@
|
||||
- Ansible Galaxy
|
||||
register: result
|
||||
|
||||
- name: Create an inventory
|
||||
inventory:
|
||||
name: "{{ inv1 }}"
|
||||
organization: "{{ org_name }}"
|
||||
|
||||
- name: Create a Demo Project
|
||||
project:
|
||||
name: "{{ proj1 }}"
|
||||
@@ -104,7 +110,7 @@
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
@@ -119,6 +125,63 @@
|
||||
that:
|
||||
- "jt1_result is changed"
|
||||
|
||||
- name: Create Job Template 1 with exists
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
- "{{ cred2 }}"
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
job_type: run
|
||||
state: exists
|
||||
register: jt1_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "jt1_result is not changed"
|
||||
|
||||
- name: Delete Job Template 1
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
- "{{ cred2 }}"
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
job_type: run
|
||||
state: absent
|
||||
register: jt1_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "jt1_result is changed"
|
||||
|
||||
- name: Create Job Template 1 with exists
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credentials:
|
||||
- "{{ cred1 }}"
|
||||
- "{{ cred2 }}"
|
||||
instance_groups:
|
||||
- "{{ group_name1 }}"
|
||||
job_type: run
|
||||
state: exists
|
||||
register: jt1_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "jt1_result is changed"
|
||||
|
||||
- name: Add a credential to this JT
|
||||
job_template:
|
||||
name: "{{ jt1 }}"
|
||||
@@ -218,7 +281,7 @@
|
||||
name: "{{ jt2 }}"
|
||||
organization: Default
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credential: "{{ cred3 }}"
|
||||
job_type: run
|
||||
@@ -236,7 +299,7 @@
|
||||
name: "{{ jt2 }}"
|
||||
organization: Default
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credential: "{{ cred3 }}"
|
||||
job_type: run
|
||||
@@ -384,7 +447,7 @@
|
||||
job_template:
|
||||
name: "{{ jt2 }}"
|
||||
project: "{{ proj1 }}"
|
||||
inventory: Demo Inventory
|
||||
inventory: "{{ inv1 }}"
|
||||
playbook: hello_world.yml
|
||||
credential: "{{ cred3 }}"
|
||||
job_type: run
|
||||
@@ -444,6 +507,12 @@
|
||||
organization: Default
|
||||
state: absent
|
||||
|
||||
- name: Delete an inventory
|
||||
inventory:
|
||||
name: "{{ inv1 }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
- name: "Remove the organization"
|
||||
organization:
|
||||
name: "{{ org_name }}"
|
||||
|
||||
@@ -13,6 +13,22 @@
|
||||
name: "{{ label_name }}"
|
||||
organization: Default
|
||||
state: present
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "results is changed"
|
||||
|
||||
- name: Create a Label with exists
|
||||
label:
|
||||
name: "{{ label_name }}"
|
||||
organization: Default
|
||||
state: exists
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "results is not changed"
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
label:
|
||||
|
||||
@@ -36,6 +36,75 @@
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Create Slack notification with custom messages with exists
|
||||
notification_template:
|
||||
name: "{{ slack_not }}"
|
||||
organization: Default
|
||||
notification_type: slack
|
||||
notification_configuration:
|
||||
token: a_token
|
||||
channels:
|
||||
- general
|
||||
messages:
|
||||
started:
|
||||
message: "{{ '{{' }} job_friendly_name {{' }}' }} {{ '{{' }} job.id {{' }}' }} started"
|
||||
success:
|
||||
message: "{{ '{{' }} job_friendly_name {{ '}}' }} completed in {{ '{{' }} job.elapsed {{ '}}' }} seconds"
|
||||
error:
|
||||
message: "{{ '{{' }} job_friendly_name {{ '}}' }} FAILED! Please look at {{ '{{' }} job.url {{ '}}' }}"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Delete Slack notification with custom messages
|
||||
notification_template:
|
||||
name: "{{ slack_not }}"
|
||||
organization: Default
|
||||
notification_type: slack
|
||||
notification_configuration:
|
||||
token: a_token
|
||||
channels:
|
||||
- general
|
||||
messages:
|
||||
started:
|
||||
message: "{{ '{{' }} job_friendly_name {{' }}' }} {{ '{{' }} job.id {{' }}' }} started"
|
||||
success:
|
||||
message: "{{ '{{' }} job_friendly_name {{ '}}' }} completed in {{ '{{' }} job.elapsed {{ '}}' }} seconds"
|
||||
error:
|
||||
message: "{{ '{{' }} job_friendly_name {{ '}}' }} FAILED! Please look at {{ '{{' }} job.url {{ '}}' }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Create Slack notification with custom messages with exists
|
||||
notification_template:
|
||||
name: "{{ slack_not }}"
|
||||
organization: Default
|
||||
notification_type: slack
|
||||
notification_configuration:
|
||||
token: a_token
|
||||
channels:
|
||||
- general
|
||||
messages:
|
||||
started:
|
||||
message: "{{ '{{' }} job_friendly_name {{' }}' }} {{ '{{' }} job.id {{' }}' }} started"
|
||||
success:
|
||||
message: "{{ '{{' }} job_friendly_name {{ '}}' }} completed in {{ '{{' }} job.elapsed {{ '}}' }} seconds"
|
||||
error:
|
||||
message: "{{ '{{' }} job_friendly_name {{ '}}' }} FAILED! Please look at {{ '{{' }} job.url {{ '}}' }}"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete Slack notification
|
||||
notification_template:
|
||||
name: "{{ slack_not }}"
|
||||
|
||||
@@ -25,6 +25,39 @@
|
||||
- assert:
|
||||
that: "result is changed"
|
||||
|
||||
- name: "Create a new organization with exists"
|
||||
organization:
|
||||
name: "{{ org_name }}"
|
||||
galaxy_credentials:
|
||||
- Ansible Galaxy
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that: "result is not changed"
|
||||
|
||||
- name: "Delete a new organization"
|
||||
organization:
|
||||
name: "{{ org_name }}"
|
||||
galaxy_credentials:
|
||||
- Ansible Galaxy
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that: "result is changed"
|
||||
|
||||
- name: "Create a new organization with exists"
|
||||
organization:
|
||||
name: "{{ org_name }}"
|
||||
galaxy_credentials:
|
||||
- Ansible Galaxy
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that: "result is changed"
|
||||
|
||||
- name: "Make sure making the same org is not a change"
|
||||
organization:
|
||||
name: "{{ org_name }}"
|
||||
|
||||
@@ -39,6 +39,48 @@
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Create a git project without credentials and wait with exists
|
||||
project:
|
||||
name: "{{ project_name1 }}"
|
||||
organization: Default
|
||||
scm_type: git
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
wait: true
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Delete a git project without credentials and wait
|
||||
project:
|
||||
name: "{{ project_name1 }}"
|
||||
organization: Default
|
||||
scm_type: git
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
wait: true
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Create a git project without credentials and wait with exists
|
||||
project:
|
||||
name: "{{ project_name1 }}"
|
||||
organization: Default
|
||||
scm_type: git
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
wait: true
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Recreate the project to validate not changed
|
||||
project:
|
||||
name: "{{ project_name1 }}"
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
jt1: "AWX-Collection-tests-role-jt1-{{ test_id }}"
|
||||
jt2: "AWX-Collection-tests-role-jt2-{{ test_id }}"
|
||||
wfjt_name: "AWX-Collection-tests-role-project-wfjt-{{ test_id }}"
|
||||
team_name: "AWX-Collection-tests-team-team-{{ test_id }}"
|
||||
team2_name: "AWX-Collection-tests-team-team-{{ test_id }}2"
|
||||
|
||||
- block:
|
||||
- name: Create a User
|
||||
@@ -27,6 +29,32 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a 2nd User
|
||||
user:
|
||||
first_name: Joe
|
||||
last_name: User
|
||||
username: "{{ username }}2"
|
||||
password: "{{ 65535 | random | to_uuid }}"
|
||||
email: joe@example.org
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create teams
|
||||
team:
|
||||
name: "{{ item }}"
|
||||
organization: Default
|
||||
register: result
|
||||
loop:
|
||||
- "{{ team_name }}"
|
||||
- "{{ team2_name }}"
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a project
|
||||
project:
|
||||
name: "{{ project_name }}"
|
||||
@@ -55,9 +83,14 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add Joe to the update role of the default Project with lookup Organization
|
||||
- name: Add Joe and teams to the update role of the default Project with lookup Organization
|
||||
role:
|
||||
user: "{{ username }}"
|
||||
users:
|
||||
- "{{ username }}2"
|
||||
teams:
|
||||
- "{{ team_name }}"
|
||||
- "{{ team2_name }}"
|
||||
role: update
|
||||
lookup_organization: Default
|
||||
project: "Demo Project"
|
||||
@@ -74,6 +107,11 @@
|
||||
- name: Add Joe to the new project by ID
|
||||
role:
|
||||
user: "{{ username }}"
|
||||
users:
|
||||
- "{{ username }}2"
|
||||
teams:
|
||||
- "{{ team_name }}"
|
||||
- "{{ team2_name }}"
|
||||
role: update
|
||||
project: "{{ project_info['id'] }}"
|
||||
state: "{{ item }}"
|
||||
@@ -89,6 +127,8 @@
|
||||
- name: Add Joe as execution admin to Default Org.
|
||||
role:
|
||||
user: "{{ username }}"
|
||||
users:
|
||||
- "{{ username }}2"
|
||||
role: execution_environment_admin
|
||||
organizations: Default
|
||||
state: "{{ item }}"
|
||||
@@ -110,6 +150,8 @@
|
||||
- name: Add Joe to workflow execute role
|
||||
role:
|
||||
user: "{{ username }}"
|
||||
users:
|
||||
- "{{ username }}2"
|
||||
role: execute
|
||||
workflow: test-role-workflow
|
||||
job_templates:
|
||||
@@ -125,6 +167,8 @@
|
||||
- name: Add Joe to nonexistant job template execute role
|
||||
role:
|
||||
user: "{{ username }}"
|
||||
users:
|
||||
- "{{ username }}2"
|
||||
role: execute
|
||||
workflow: test-role-workflow
|
||||
job_templates:
|
||||
@@ -141,6 +185,8 @@
|
||||
- name: Add Joe to workflow execute role, no-op
|
||||
role:
|
||||
user: "{{ username }}"
|
||||
users:
|
||||
- "{{ username }}2"
|
||||
role: execute
|
||||
workflow: test-role-workflow
|
||||
state: present
|
||||
@@ -153,6 +199,8 @@
|
||||
- name: Add Joe to workflow approve role
|
||||
role:
|
||||
user: "{{ username }}"
|
||||
users:
|
||||
- "{{ username }}2"
|
||||
role: approval
|
||||
workflow: test-role-workflow
|
||||
state: present
|
||||
@@ -170,6 +218,23 @@
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: Delete a 2nd User
|
||||
user:
|
||||
username: "{{ username }}2"
|
||||
email: joe@example.org
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: Delete teams
|
||||
team:
|
||||
name: "{{ item }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
register: result
|
||||
loop:
|
||||
- "{{ team_name }}"
|
||||
- "{{ team2_name }}"
|
||||
|
||||
- name: Delete job templates
|
||||
job_template:
|
||||
name: "{{ item }}"
|
||||
|
||||
@@ -76,6 +76,42 @@
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Build a real schedule with exists
|
||||
schedule:
|
||||
name: "{{ sched1 }}"
|
||||
state: exists
|
||||
unified_job_template: "Demo Job Template"
|
||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Delete a real schedule
|
||||
schedule:
|
||||
name: "{{ sched1 }}"
|
||||
state: absent
|
||||
unified_job_template: "Demo Job Template"
|
||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Build a real schedule with exists
|
||||
schedule:
|
||||
name: "{{ sched1 }}"
|
||||
state: exists
|
||||
unified_job_template: "Demo Job Template"
|
||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Rebuild the same schedule
|
||||
schedule:
|
||||
name: "{{ sched1 }}"
|
||||
|
||||
@@ -34,6 +34,39 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a team with exists
|
||||
team:
|
||||
name: "{{ team_name }}"
|
||||
organization: Default
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete a team
|
||||
team:
|
||||
name: "{{ team_name }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a team with exists
|
||||
team:
|
||||
name: "{{ team_name }}"
|
||||
organization: Default
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete a team
|
||||
team:
|
||||
name: "{{ team_name }}"
|
||||
|
||||
@@ -20,6 +20,42 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a User with exists
|
||||
user:
|
||||
username: "{{ username }}"
|
||||
first_name: Joe
|
||||
password: "{{ 65535 | random | to_uuid }}"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete a User
|
||||
user:
|
||||
username: "{{ username }}"
|
||||
first_name: Joe
|
||||
password: "{{ 65535 | random | to_uuid }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a User with exists
|
||||
user:
|
||||
username: "{{ username }}"
|
||||
first_name: Joe
|
||||
password: "{{ 65535 | random | to_uuid }}"
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Change a User by ID
|
||||
user:
|
||||
username: "{{ result.id }}"
|
||||
|
||||
@@ -254,6 +254,65 @@
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a workflow job template with exists
|
||||
workflow_job_template:
|
||||
name: "{{ wfjt_name }}"
|
||||
organization: Default
|
||||
inventory: Demo Inventory
|
||||
extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}}
|
||||
labels:
|
||||
- "{{ lab1 }}"
|
||||
ask_inventory_on_launch: true
|
||||
ask_scm_branch_on_launch: true
|
||||
ask_limit_on_launch: true
|
||||
ask_tags_on_launch: true
|
||||
ask_variables_on_launch: true
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not changed"
|
||||
|
||||
- name: Delete a workflow job template
|
||||
workflow_job_template:
|
||||
name: "{{ wfjt_name }}"
|
||||
organization: Default
|
||||
inventory: Demo Inventory
|
||||
extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}}
|
||||
labels:
|
||||
- "{{ lab1 }}"
|
||||
ask_inventory_on_launch: true
|
||||
ask_scm_branch_on_launch: true
|
||||
ask_limit_on_launch: true
|
||||
ask_tags_on_launch: true
|
||||
ask_variables_on_launch: true
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a workflow job template with exists
|
||||
workflow_job_template:
|
||||
name: "{{ wfjt_name }}"
|
||||
organization: Default
|
||||
inventory: Demo Inventory
|
||||
extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}}
|
||||
# We don't try with the label here because after we delete the first WFJT the label is delete with it because it has no references
|
||||
ask_inventory_on_launch: true
|
||||
ask_scm_branch_on_launch: true
|
||||
ask_limit_on_launch: true
|
||||
ask_tags_on_launch: true
|
||||
ask_variables_on_launch: true
|
||||
state: exists
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a workflow job template with bad label
|
||||
workflow_job_template:
|
||||
name: "{{ wfjt_name }}"
|
||||
|
||||
@@ -110,7 +110,7 @@ processes it spawns. This allows Ansible events to be captured and persisted
|
||||
into the AWX database; this process is what drives the "streaming" web UI
|
||||
you'll see if you launch a job from the AWX web interface and watch its results
|
||||
appears on the screen. AWX relies on stability in this plugin interface, the
|
||||
heirarchy of emitted events based on strategy, and _especially_ the structure
|
||||
hierarchy of emitted events based on strategy, and _especially_ the structure
|
||||
of event data to work across Ansible releases:
|
||||
|
||||

|
||||
|
||||
Reference in New Issue
Block a user