-1

How can you test(-run) an ansible role on your localhost?

So far I have done this on my ubuntu 16.04 machine:

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible
$ ansible-galaxy install -p roles -r requirements.yml

Where requirements.yml contains:

- src: https://github.com/florianutz/Ubuntu1604-CIS.git

This installs that role successfully. Now, I'm not sure what to do next. I just want to apply that role on localhost. Is there a simple way to do that?

user1511417
  • 131
  • 2
  • 6
  • The [README](https://github.com/florianutz/Ubuntu1604-CIS) is quite clear on what you need to do. Have you read it? Also, this is something you really should not run until you understand fully what changes it makes, and absolutely not on your local host. Run it on a fresh virtual machine until you are fully satisfied it does what you want. – Michael Hampton Oct 01 '18 at 11:51
  • Yes, I've read the README and I am using a VM of course. Florian's README shows me how to install this Ubuntu-role, but not how to actually apply this role to a machine. – user1511417 Oct 01 '18 at 12:04
  • That's strange, because the answer you posted exactly matches the example given in the README. If that didn't actually answer your question, then I wasn't clear on what your question actually is. – Michael Hampton Oct 01 '18 at 13:48
  • The README-example provides a simple playbook, but no information on how to quickstart this on your machine. – user1511417 Oct 01 '18 at 13:53

1 Answers1

0

You can run a local ansible playbook for that specific case like this:

First, create a .yml-file with this content

- name: Harden Ubuntu 16.04
  hosts: 127.0.0.1
  connection: local
  become: yes
  roles:
    - Ubuntu1604-CIS

then run ansible locally with

$ sudo ansible-playbook -K YOUR.yml
user1511417
  • 131
  • 2
  • 6