From cac55beb4fe7e22f2d4d868fef3affbb854e558f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 21 Jul 2024 21:05:34 +0200 Subject: [PATCH] Type options of callback plugins (#8628) Type options of callback plugins. --- changelogs/fragments/8628-callback-types.yml | 2 ++ plugins/callback/cgroup_memory_recap.py | 2 ++ plugins/callback/hipchat.py | 7 +++++++ plugins/callback/jabber.py | 4 ++++ plugins/callback/log_plays.py | 1 + plugins/callback/loganalytics.py | 2 ++ plugins/callback/logentries.py | 4 ++++ plugins/callback/logstash.py | 4 ++++ plugins/callback/slack.py | 3 +++ plugins/callback/splunk.py | 2 ++ plugins/callback/sumologic.py | 1 + plugins/callback/syslog_json.py | 3 +++ 12 files changed, 35 insertions(+) create mode 100644 changelogs/fragments/8628-callback-types.yml diff --git a/changelogs/fragments/8628-callback-types.yml b/changelogs/fragments/8628-callback-types.yml new file mode 100644 index 0000000000..c223a85985 --- /dev/null +++ b/changelogs/fragments/8628-callback-types.yml @@ -0,0 +1,2 @@ +minor_changes: + - "cgroup_memory_recap, hipchat, jabber, log_plays, loganalytics, logentries, logstash, slack, splunk, sumologic, syslog_json callback plugins - make sure that all options are typed (https://github.com/ansible-collections/community.general/pull/8628)." diff --git a/plugins/callback/cgroup_memory_recap.py b/plugins/callback/cgroup_memory_recap.py index d3961bf0c8..643f0f0b88 100644 --- a/plugins/callback/cgroup_memory_recap.py +++ b/plugins/callback/cgroup_memory_recap.py @@ -25,6 +25,7 @@ DOCUMENTATION = ''' max_mem_file: required: true description: Path to cgroups C(memory.max_usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.max_usage_in_bytes). + type: str env: - name: CGROUP_MAX_MEM_FILE ini: @@ -33,6 +34,7 @@ DOCUMENTATION = ''' cur_mem_file: required: true description: Path to C(memory.usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.usage_in_bytes). + type: str env: - name: CGROUP_CUR_MEM_FILE ini: diff --git a/plugins/callback/hipchat.py b/plugins/callback/hipchat.py index afd9e20559..bf0d425303 100644 --- a/plugins/callback/hipchat.py +++ b/plugins/callback/hipchat.py @@ -25,6 +25,7 @@ DOCUMENTATION = ''' options: token: description: HipChat API token for v1 or v2 API. + type: str required: true env: - name: HIPCHAT_TOKEN @@ -33,6 +34,10 @@ DOCUMENTATION = ''' key: token api_version: description: HipChat API version, v1 or v2. + type: str + choices: + - v1 + - v2 required: false default: v1 env: @@ -42,6 +47,7 @@ DOCUMENTATION = ''' key: api_version room: description: HipChat room to post in. + type: str default: ansible env: - name: HIPCHAT_ROOM @@ -50,6 +56,7 @@ DOCUMENTATION = ''' key: room from: description: Name to post as + type: str default: ansible env: - name: HIPCHAT_FROM diff --git a/plugins/callback/jabber.py b/plugins/callback/jabber.py index d2d00496d8..302687b708 100644 --- a/plugins/callback/jabber.py +++ b/plugins/callback/jabber.py @@ -20,21 +20,25 @@ DOCUMENTATION = ''' options: server: description: connection info to jabber server + type: str required: true env: - name: JABBER_SERV user: description: Jabber user to authenticate as + type: str required: true env: - name: JABBER_USER password: description: Password for the user to the jabber server + type: str required: true env: - name: JABBER_PASS to: description: chat identifier that will receive the message + type: str required: true env: - name: JABBER_TO diff --git a/plugins/callback/log_plays.py b/plugins/callback/log_plays.py index e99054e176..daa88bcc11 100644 --- a/plugins/callback/log_plays.py +++ b/plugins/callback/log_plays.py @@ -21,6 +21,7 @@ DOCUMENTATION = ''' log_folder: default: /var/log/ansible/hosts description: The folder where log files will be created. + type: str env: - name: ANSIBLE_LOG_FOLDER ini: diff --git a/plugins/callback/loganalytics.py b/plugins/callback/loganalytics.py index ed7e47b2e2..fd1b2772c4 100644 --- a/plugins/callback/loganalytics.py +++ b/plugins/callback/loganalytics.py @@ -21,6 +21,7 @@ DOCUMENTATION = ''' options: workspace_id: description: Workspace ID of the Azure log analytics workspace. + type: str required: true env: - name: WORKSPACE_ID @@ -29,6 +30,7 @@ DOCUMENTATION = ''' key: workspace_id shared_key: description: Shared key to connect to Azure log analytics workspace. + type: str required: true env: - name: WORKSPACE_SHARED_KEY diff --git a/plugins/callback/logentries.py b/plugins/callback/logentries.py index d3feceb72e..c1271543ad 100644 --- a/plugins/callback/logentries.py +++ b/plugins/callback/logentries.py @@ -22,6 +22,7 @@ DOCUMENTATION = ''' options: api: description: URI to the Logentries API. + type: str env: - name: LOGENTRIES_API default: data.logentries.com @@ -30,6 +31,7 @@ DOCUMENTATION = ''' key: api port: description: HTTP port to use when connecting to the API. + type: int env: - name: LOGENTRIES_PORT default: 80 @@ -38,6 +40,7 @@ DOCUMENTATION = ''' key: port tls_port: description: Port to use when connecting to the API when TLS is enabled. + type: int env: - name: LOGENTRIES_TLS_PORT default: 443 @@ -46,6 +49,7 @@ DOCUMENTATION = ''' key: tls_port token: description: The logentries C(TCP token). + type: str env: - name: LOGENTRIES_ANSIBLE_TOKEN required: true diff --git a/plugins/callback/logstash.py b/plugins/callback/logstash.py index f3725e465a..aa47ee4eb8 100644 --- a/plugins/callback/logstash.py +++ b/plugins/callback/logstash.py @@ -20,6 +20,7 @@ DOCUMENTATION = r''' options: server: description: Address of the Logstash server. + type: str env: - name: LOGSTASH_SERVER ini: @@ -29,6 +30,7 @@ DOCUMENTATION = r''' default: localhost port: description: Port on which logstash is listening. + type: int env: - name: LOGSTASH_PORT ini: @@ -38,6 +40,7 @@ DOCUMENTATION = r''' default: 5000 type: description: Message type. + type: str env: - name: LOGSTASH_TYPE ini: @@ -47,6 +50,7 @@ DOCUMENTATION = r''' default: ansible pre_command: description: Executes command before run and its result is added to the C(ansible_pre_command_output) logstash field. + type: str version_added: 2.0.0 ini: - section: callback_logstash diff --git a/plugins/callback/slack.py b/plugins/callback/slack.py index e7a2743ec5..2a995992ee 100644 --- a/plugins/callback/slack.py +++ b/plugins/callback/slack.py @@ -22,6 +22,7 @@ DOCUMENTATION = ''' webhook_url: required: true description: Slack Webhook URL. + type: str env: - name: SLACK_WEBHOOK_URL ini: @@ -30,6 +31,7 @@ DOCUMENTATION = ''' channel: default: "#ansible" description: Slack room to post in. + type: str env: - name: SLACK_CHANNEL ini: @@ -37,6 +39,7 @@ DOCUMENTATION = ''' key: channel username: description: Username to post as. + type: str env: - name: SLACK_USERNAME default: ansible diff --git a/plugins/callback/splunk.py b/plugins/callback/splunk.py index a3e401bc21..b2ce48de25 100644 --- a/plugins/callback/splunk.py +++ b/plugins/callback/splunk.py @@ -22,6 +22,7 @@ DOCUMENTATION = ''' options: url: description: URL to the Splunk HTTP collector source. + type: str env: - name: SPLUNK_URL ini: @@ -29,6 +30,7 @@ DOCUMENTATION = ''' key: url authtoken: description: Token to authenticate the connection to the Splunk HTTP collector. + type: str env: - name: SPLUNK_AUTHTOKEN ini: diff --git a/plugins/callback/sumologic.py b/plugins/callback/sumologic.py index 0304b9de52..32ca6e0ed0 100644 --- a/plugins/callback/sumologic.py +++ b/plugins/callback/sumologic.py @@ -20,6 +20,7 @@ requirements: options: url: description: URL to the Sumologic HTTP collector source. + type: str env: - name: SUMOLOGIC_URL ini: diff --git a/plugins/callback/syslog_json.py b/plugins/callback/syslog_json.py index 43d6ff2f9f..9066d8d9c5 100644 --- a/plugins/callback/syslog_json.py +++ b/plugins/callback/syslog_json.py @@ -19,6 +19,7 @@ DOCUMENTATION = ''' options: server: description: Syslog server that will receive the event. + type: str env: - name: SYSLOG_SERVER default: localhost @@ -27,6 +28,7 @@ DOCUMENTATION = ''' key: syslog_server port: description: Port on which the syslog server is listening. + type: int env: - name: SYSLOG_PORT default: 514 @@ -35,6 +37,7 @@ DOCUMENTATION = ''' key: syslog_port facility: description: Syslog facility to log as. + type: str env: - name: SYSLOG_FACILITY default: user