Display help on Ansible standard module. :param module: The module to get the help CLI Example: .. code-block:: bash salt * ansible.help ping
(module=None, *args)
| 146 | |
| 147 | |
| 148 | def help(module=None, *args): |
| 149 | """ |
| 150 | Display help on Ansible standard module. |
| 151 | |
| 152 | :param module: The module to get the help |
| 153 | |
| 154 | CLI Example: |
| 155 | |
| 156 | .. code-block:: bash |
| 157 | |
| 158 | salt * ansible.help ping |
| 159 | """ |
| 160 | if not module: |
| 161 | raise CommandExecutionError( |
| 162 | "Please tell me what module you want to have helped with. " |
| 163 | 'Or call "ansible.list" to know what is available.' |
| 164 | ) |
| 165 | |
| 166 | ansible_doc_bin = salt.utils.path.which("ansible-doc") |
| 167 | |
| 168 | env = os.environ.copy() |
| 169 | env["ANSIBLE_DEPRECATION_WARNINGS"] = "0" |
| 170 | |
| 171 | proc = subprocess.run( |
| 172 | [ansible_doc_bin, "--json", "--type=module", module], |
| 173 | capture_output=True, |
| 174 | check=True, |
| 175 | shell=False, |
| 176 | text=True, |
| 177 | env=env, |
| 178 | ) |
| 179 | data = salt.utils.json.loads(proc.stdout) |
| 180 | doc = data[next(iter(data))] |
| 181 | if not args: |
| 182 | ret = doc["doc"] |
| 183 | for section in ("examples", "return", "metadata"): |
| 184 | section_data = doc.get(section) |
| 185 | if section_data: |
| 186 | ret[section] = section_data |
| 187 | else: |
| 188 | ret = {} |
| 189 | for arg in args: |
| 190 | info = doc.get(arg) |
| 191 | if info is not None: |
| 192 | ret[arg] = info |
| 193 | return ret |
| 194 | |
| 195 | |
| 196 | def list_(pattern=None): |
nothing calls this directly
no test coverage detected