Giter Club home page Giter Club logo

ansible-truenas's Introduction

Ansible Collection - arensb.truenas

Manage a TrueNAS machine.

Included content

This collection consists primarily of a set of Ansible modules to configure a TrueNAS machine, using the TrueNAS API to control the Middleware Daemon.

There are several ways to talk to the Middleware, but at present this collection only supports running midclt commands on the box. So you will need root access there, just as for any other Ansible client. In the future, it may support RESTful control.

See the online documentation for details on each included module.

Installing this collection

The easiest way to install this collection is through Ansible Galaxy:

ansible-galaxy collection install arensb.truenas

Examples

- name: Example tasks
  collections:
    - arensb.truenas
  hosts: truenas-box
  become: yes
  tasks:
    - name: Set the hostname
      hostname:
        name: new-hostname
    - name: Turn on sshd
      service:
        name: sshd

Note that since several of the module names are the same as builtin ones, you may want to use the full name to avoid confusion:

- hosts: truenas-box
  become: yes
  tasks:
    - arensb.truenas.hostname:
        name: new-hostname

Environment Variables

middleware_method

There are two ways of communicating with the middleware daemon on TrueNAS, referred to here as midclt and client. midclt is older and better-tested, while client is faster but less-well-tested. The default is client.

Set the middleware_method environment variable to either client or midclt at either the play or task level in your playbook to manually select how this module communicates with the middleware daemon.

Example:

- collections: arensb.truenas
  hosts: my-nas
  become: yes
  environment:
    middleware_method: client
  tasks:
    - name: Create a jail
      jail:
        name: my-jail
        release: 13.1-RELEASE
        state: running

Contributing to this collection

The best way to contribute a patch or feature is to create a pull request.

If you'd like to write your own module, the extras/template file provides a good starting point.

The HACKING file has some tips on how to get around.

Documentation

See the online documentation.

Supported versions of Ansible

  • Tested with 2.10.8

Changelog

See the user-friendly docs, or the latest changelog.yaml.

Authors and Contributors

ansible-truenas's People

Contributors

arensb avatar edhull avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

edhull crpb nmisha

ansible-truenas's Issues

nfs module - additional parameters

the nfs module currently supports nfsv4 which sets v4 to a bool, but doesn't allow other parameters to be set

Would it be possible to add v4_v3owner (also a bool) to that module such that it can be changed through ansible?

PS: I'm only interested in this v4_v3owner, but other people may want to configure the other params as well

Create a test suite

At present, there's no test suite, no CI/CD pipeline, no regression testing. If someone who knows more about CI/CD and testing than I do could add a test suite, with examples of how to add new tests, that would allow contributors to at least do some basic testing before trying code out on a live installation.

user set sudo don't work on truenas scale

We run TrueNAS-SCALE-22.12.2 and use ansible-truenas 1.4.4
To manage user works, until I try to manage sudo per user.
The yaml API on ansible-truenas site don't match what trusnas is doing.
ansible-truenas:
sudo enable bool
sudo_nopassword bool
sudo_commands array of commands

TrueNAS-SCALE-22.12.2 midcli
sudo_commands array of commands with password
sudo_commands_nopasswd array of commands with no password needed

How we would get this working?
a)Translate from ansible-truenas api to TrueNAS-SCALE api
b) change ansible-truenas api to TrueNAS-SCALE api

truenas.service doesn't start nor enables services

setup:

  • TrueNAS-13.0-U5.3 (running through virt manager)
  • ansible collection arensb.truenas version 1.7.0
  • ansible version 2.15.2

for some reason, it doesn't seem to start services I have defined

this is my roles/truenas/tasks/main.yml that I'm using

---
- name: Create an ordinary user and their group
  arensb.truenas.user:
    name: testuser
    create_group: true
    sudo_commands: ALL
    password: "testpwd"

- name: Configure NFS exports
  arensb.truenas.sharing_nfs:
    enabled: true
    name: media nfs share
    path: /mnt/tank/data/media
    maproot_user: testuser
    maproot_group: testuser

- name: Enable NFSv4
  arensb.truenas.nfs:
    nfsv4: true

- name: Enable services
  arensb.truenas.service:
    name: "{{ item }}"
    enabled: true
    state: started
  with_items:
    - ssh
    - nfs

The last step is to enable ssh and nfs. SSH is already started which allows ansible to run, but it doesn't enable it. Also it doesn't seem to enable and start the nfs service.

Running ansible-playbook -vvv playbooks/truenas.yml gives me

<[email protected]> ESTABLISH SSH CONNECTION FOR USER: None
<[email protected]> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/paulo/.ansible/cp/e04ab7b04b"' [email protected] '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1691781720.9827127-9421-115081788509640/ /root/.ansible/tmp/ansible-tmp-1691781720.9827127-9421-115081788509640/AnsiballZ_service.py && sleep 0'"'"''
<[email protected]> (0, b'', b'')
<[email protected]> ESTABLISH SSH CONNECTION FOR USER: None
<[email protected]> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/paulo/.ansible/cp/e04ab7b04b"' -tt [email protected] '/bin/sh -c '"'"'/usr/local/bin/python3.9 /root/.ansible/tmp/ansible-tmp-1691781720.9827127-9421-115081788509640/AnsiballZ_service.py && sleep 0'"'"''
<[email protected]> (0, b'\r\n{"changed": false, "msg": "", "service_id": 11, "name": "ssh", "enabled": false, "state": "RUNNING", "pids": [1540], "invocation": {"module_args": {"name": "ssh", "enabled": true, "state": "started", "ha_propagate": null}}}\r\n', b'Shared connection to 192.168.122.100 closed.\r\n')
[email protected]> ESTABLISH SSH CONNECTION FOR USER: None
<[email protected]> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/paulo/.ansible/cp/e04ab7b04b"' [email protected] '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1691781720.9827127-9421-115081788509640/ > /dev/null 2>&1 && sleep 0'"'"''
<[email protected]> (0, b'', b'')
ok: [[email protected]] => (item=ssh) => {
    "ansible_loop_var": "item",
    "changed": false,
    "enabled": false,
    "invocation": {
        "module_args": {
            "enabled": true,
            "ha_propagate": null,
            "name": "ssh",
            "state": "started"
        }
    },
    "item": "ssh",
    "msg": "",
    "name": "ssh",
    "pids": [
        1540
    ],
    "service_id": 11,
    "state": "RUNNING"
}
...
...
<[email protected]> ESTABLISH SSH CONNECTION FOR USER: None
<[email protected]> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/paulo/.ansible/cp/e04ab7b04b"' -tt [email protected] '/bin/sh -c '"'"'/usr/local/bin/python3.9 /root/.ansible/tmp/ansible-tmp-1691781721.2552562-9421-21221030135877/AnsiballZ_service.py && sleep 0'"'"''
<[email protected]> (0, b'\r\n{"changed": false, "msg": "", "service_id": 9, "name": "nfs", "enabled": false, "state": "STOPPED", "pids": [], "invocation": {"module_args": {"name": "nfs", "enabled": true, "state": "started", "ha_propagate": null}}}\r\n', b'Shared connection to 192.168.122.100 closed.\r\n')
<[email protected]> ESTABLISH SSH CONNECTION FOR USER: None
<[email protected]> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/paulo/.ansible/cp/e04ab7b04b"' [email protected] '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1691781721.2552562-9421-21221030135877/ > /dev/null 2>&1 && sleep 0'"'"''
<[email protected]> (0, b'', b'')
ok: [[email protected]] => (item=nfs) => {
    "ansible_loop_var": "item",
    "changed": false,
    "enabled": false,
    "invocation": {
        "module_args": {
            "enabled": true,
            "ha_propagate": null,
            "name": "nfs",
            "state": "started"
        }
    },
    "item": "nfs",
    "msg": "",
    "name": "nfs",
    "pids": [],
    "service_id": 9,
    "state": "STOPPED"
}

Notice that ansible doesn't return errors, but returns state: STOPPED when it shouldn't

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.