Security Automation with Ansible 2
上QQ阅读APP看书,第一时间看更新

Setting up Rundeck

The following Ansible playbook will set up Rundeck on the Ubuntu 16.04 OS.  It also adds the Rundeck service to start up the process:

- name: installing rundeck on ubuntu 16.04
  hosts: "192.168.1.7"
  remote_user: ubuntu
  gather_facts: False
  become: True

  tasks:
    - name: installing python2 minimal
      raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)

    - name: java and curl installation
      apt:
name: "{{ item }}"
state: present
update_cache: yes
with_items: - curl - openjdk-8-jdk - name: downloading and installing rundeck deb package apt: deb: "http://dl.bintray.com/rundeck/rundeck-deb/rundeck-2.8.4-1-GA.deb" - name: add to startup and start rundeck service: name: rundeckd state: started

To set up Rundeck, run the following command. Where 192.168.1.7 is the server IP address where Rundeck will install:

ansible-playbook -i '192.168.1.7,' site.yml --ask-sudo-pass

Once it is successfully executed, navigate the browser to http://192.168.1.7:4440 and you can see the login panel for the Rundeck application. The default username and password to log in to Rundeck is admin:

Now we can create a new project to start working on. Provide a new Project Name and go with the default settings for now:

Now, we can add multiple hosts into Rundeck to perform multiple actions. The following screenshot shows an example of running the  uname -a command across multiple nodes, which matches osArch: amd64, we can also create filters for different use cases:

Using Rundeck, we can also schedule jobs to run at certain times and store the output in different formats. Rundeck also provides a REST API that can be integrated into the existing tool set.