0

This is going to be long, so sorry about that, but no one seems to be able to help... Keep in mind, this is not my homework !! This is a project I get payed for, but I can't find any info about this, and I'm getting scared I can't even do this ...

I'm part of a project where we have to set up a virtual environment with gitlab, alfresco etc, make users, automatize commits and such with Ansible. We need this for advanced pen-testing and security purposes, a realistic playground of sorts.

I'm setting up Gitlab, which worked fine but now I have problems making users, I can't get the gitlab_user ansible module to work, there isn't a single example of how to use it and the given example playbooks don't work either ... Can someone please help me figure out the syntax ? Do I have to run a playbook with this in it ? :

- name: Create Gitlab User
  gitlab_user:
    server_url: https://gitlab.dj-wasabi.local
    validate_certs: True
    login_user: dj-wasabi
    login_password: MySecretPassword
    name: My Name
    username: myusername
    password: mysecretpassword
    email: me@example.com
    sshkey_name: MySSH
    sshkey_file: ssh-rsa AAAAB3NzaC1yc...
    state: present
  delegate_to: localhost 

Or if I have to use it as a command from terminal, how do I do that ? I joined up a google group to ask about this and no one answered for days.

I thought if I can't get it to work, I'll use LDAP for user management, but can I do that ? Or LDAP is only for authentication and I have to make users with gitlab either way ? This is something I don't really understand about GitLab itself ...

None the less I tried setting up Slapd with the ansible role debops.slapd. I found this question here, but when I copied the code and ran the playbook it simply gave me this:

    PLAY [Manage OpenLDAP service] *************************************************

TASK [Gathering Facts] *********************************************************
ok: [ansitest1@192.168.1.71]

TASK [debops.slapd : Make sure that Ansible local facts directory exists] ******
ok: [ansitest1@192.168.1.71]

TASK [debops.slapd : Save APT local facts] *************************************
ok: [ansitest1@192.168.1.71]

TASK [debops.slapd : Update Ansible facts if they were modified] ***************
skipping: [ansitest1@192.168.1.71]

TASK [debops.slapd : Install required packages] ********************************
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via 
squash_actions is deprecated. Instead of using a loop to supply multiple items 
and specifying `name: {{ item }}`, please use `name: [u'{{ apt__base_packages 
}}', u'{{ apt__packages }}']` and remove the loop. This feature will be removed
 in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
ok: [ansitest1@192.168.1.71] => (item=[u'apt-transport-https', u'ca-certificates'])

TASK [debops.slapd : Ensure that APT default configuration is absent] **********
ok: [ansitest1@192.168.1.71]

TASK [debops.slapd : Generate APT configuration files] *************************
ok: [ansitest1@192.168.1.71] => (item=etc/apt/apt.conf.d/25no-recommends.conf)

TASK [debops.slapd : Check current APT diversions] *****************************
ok: [ansitest1@192.168.1.71]

TASK [debops.slapd : Divert original /etc/apt/sources.list] ********************
skipping: [ansitest1@192.168.1.71]

TASK [debops.slapd : Configure APT distribution sources] ***********************
ok: [ansitest1@192.168.1.71]

TASK [debops.slapd : Remove diversion of original /etc/apt/sources.list] *******
skipping: [ansitest1@192.168.1.71]

TASK [debops.slapd : Configure custom APT keys] ********************************

TASK [debops.slapd : Configure custom APT repositories] ************************

TASK [debops.slapd : Generate additionnal APT configuration files] *************

TASK [debops.slapd : Delete APT configuration files on remote hosts] ***********

TASK [debops.slapd : Remove old unattended-upgrades configuration] *************
ok: [ansitest1@192.168.1.71] => (item=25auto-upgrades.conf)
ok: [ansitest1@192.168.1.71] => (item=55unattended-upgrades.conf)

TASK [debops.slapd : Update APT cache] *****************************************
ok: [ansitest1@192.168.1.71]

TASK [debops.slapd : Update the role status in local facts] ********************
skipping: [ansitest1@192.168.1.71]

TASK [debops.slapd : Update Ansible facts if they were modified] ***************
skipping: [ansitest1@192.168.1.71]

PLAY RECAP *********************************************************************
ansitest1@192.168.1.71     : ok=10   changed=0    unreachable=0    failed=0   

As you can see, it sure as hell doesn't set up anything, I even copied the example playbook one of the answers suggested and it didn't work either.

The VM I'm trying to set up slapd on is a simple Xubuntu installation, I'm using Mint, I'm not entirely sure if it's important ...

Now here's the question, I know that neither the debos role, nor the gitlab_user module have been touched for years at this point, do you think there's a change I can get it to wrok, or I have to write a playbook myself to set up slapd and add users to gitlab ?

And if that's the case, can I even do that ? I looked up digital ocean and it seems like I can set up Slapd, and even add users and such with Ldif files based on this page. What I'm not sure about is adding users to Gitlab ...

Again I'm terribly sorry the question is so long and complex, but there's nothing I found about any of this, and the google group is silent. Should I make this into multiple, short questions ?

Thank you for your time and help anyways ! (my first language isn't english, sorry for the mistakes )

  • Naturally, I changed the default values of the gitlab_module code I pasted above, I just deleted it and had to use the example. – Zombor Mate Nov 04 '18 at 11:56
  • Hi. What do you mean you couldn't get the gitlab module to work what was the result when you ran it. Was there an error or are you asking how to run the gitlab user module? – Peter Halligan Nov 04 '18 at 19:37
  • Sorry I guess I didn't really talk about that, I got the error: "gitlab_user is not a valid attribute for a Play" anyways, yes, I'm basically asking how to run the command, do I need a playbook ? If not, how do I use it in a terminal ? It might've simply missed an example picture or something, and that's why I can't figure it out ... – Zombor Mate Nov 05 '18 at 20:01

1 Answers1

0

The example you have shown with the gitlab_user module is a task. This needs to be a task under a play. Below is an example playbook with a single play in it. You would call this in the usual way using ansible-playbook.

White space is important if the indentation is wrong it can also cause "error: "gitlab_user is not a valid attribute for a Play" because the Ansible reads it as part of the play level not the task level

---
- hosts: <hosts_to_run_play_on>
  vars:
    var1: <foo>
    var2: <bar>
  remote_user: <user>
  become: yes
  tasks:
    - name: Create Gitlab User
      gitlab_user:
      server_url: https://gitlab.dj-wasabi.local
      validate_certs: True
      login_user: dj-wasabi
      login_password: MySecretPassword
      name: My Name
      username: myusername
      password: mysecretpassword
      email: me@example.com
      sshkey_name: MySSH
      sshkey_file: ssh-rsa AAAAB3NzaC1yc...
      state: present

anible-playbook intro

Also ensure the requirements are met as outlined by the module documentation.

  • pyapi-gitlab python module
  • administrator rights on the Gitlab server

gitlab_document

Peter Halligan
  • 662
  • 5
  • 14
  • Thank you, this helped me out a lot, I actually realised I forgot to make it a task, just added it to a playbook like that ... Do you by any chance know your way around ansible ? In case other questins come up ... – Zombor Mate Nov 08 '18 at 21:27
  • Happy I could help. I haven't worked with it for a year or so. If you have other questions there is no harm in asking me but im pretty rusty. – Peter Halligan Nov 08 '18 at 22:25
  • There is one, but I guess I should probably make another question. Thanks anyway ! – Zombor Mate Nov 10 '18 at 16:19