jame2981
jame2981

Reputation: 51

Develop ansible call another module

I am developing an a Ansible module for compile sources, like

- source_compile: archive: /var/cache/sources/nginx.tar.gz configure: prefix: /usr

I will probably

  1. Check source package. (If is url download it)
  2. Make a unique build directory.
  3. Unarchive source to build directory.
  4. configure && make && make install

So I want use ansible core module get_url and unarchive and shell, But no found how.

Upvotes: 3

Views: 2809

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68269

You can execute other modules only from action plugin, not from module itself.
It's done with _execute_module helper function. See template action for example.

Also you may be interested in using other helper functions such as fetch_url to retrieve remote data and _low_level_execute_command to run shell commands instead of calling other modules.

I'd recommend inspecting Ansible core modules/actions sources code to get the idea of how things work.

Upvotes: 6

Related Questions