Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: automate the removal of JC agent and users #6

Merged
merged 3 commits into from
Nov 9, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add the script
  • Loading branch information
marcomc committed Nov 9, 2016
commit b670ff1f76731b8d3d3b1e5f843e3aa6cf784260
4 changes: 4 additions & 0 deletions ansible_tasks/inventory.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[project_name]
production.client.com ansible_user=root ansible_ssh_pass=password_for_this_server
uat.client.com ansible_user=root ansible_ssh_pass=password_for_this_server
qa.client.com ansible_user=root ansible_ssh_pass=password_for_this_server
57 changes: 57 additions & 0 deletions ansible_tasks/remove_jc_from_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
- hosts: all
gather_facts: true
become: yes
become_method: sudo

tasks:
- name: stop jcagent
service: name=jcagent state=stopped
ignore_errors: true

- name: remove jcagent from apt based system
apt:
name: jcagent
state: absent
when: ansible_pkg_mgr == 'apt'

- name: remove jcagent from yum based system
yum:
name: jcagent
state: absent
when: ansible_pkg_mgr == 'yum'

- name: remove /opt/jc diretory
file: path=/opt/jc state=absent

# - name: update RSA KEY
# lineinfile: dest=/home/deploy/.ssh/authorized_keys regexp='^dreams@webistrano' line='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDNiLd5rpo+K+Lg3vzEXljFuITg+5eKBz7aCgpW61Nfd+oayHmp0FWsJtcSfCPAEqQ8jS18EYFHJ628t750AmQH0jB1Y5Qy5ItIjo3QRzXevh+YeAOlXPXvAQ1cy3NVYwqhEIYqC8y0fa3jXY5hQjT+NLyrnzcaAhqxVrXbY0xsyL+RZaHBZA3UitDU3Ri1HaGUKAkh2+gXpzn+n1+KivfmviZ+NIvXoZWC94txydcbEzAxBbK1BbUzgVvAn1x4Jnu4Ya3rSJklbRZdWUgTEsJtP51/+auJvnWdcR4a7M/nCxW4CmNlSrkZ5Xvstsnpz6N0HxfyxCmgjO604FzMj4ZkkbjG8xrADrx5YH85EbwxYI3CVvaH9EDt2o/r/zp4d/mIf847nTlbJgMWxV3Q1nsR/gMyUhEdHY9ZA3hiKK5/DDyjRR6me+9EjCac117qD0VcTmkqStlPj1fQjJP99yFP7kJhWMWL0qun8nIAp8CpGIpnoIXHsRy112gdYyyUqoJq0Jk/OQz0fbmTBrB0D0FF646pysjUbAOEYv37hVZ770LExz6KGL/J7R+VoJ4xCMGLffYnE7NKnfgCSL163129yjGom7etwYlpbzMhRd4E1KXevNd0KRsaq7fEPO7s/r8i5n7Q71zH84PKpo6b8RUmvNtSgKvzAR1MmSLHgLm01Q== dreams@webistrano'
#
# - name: find authorized_keys
# command: cat /home/deploy/.ssh/authorized_keys
- name: delete users_list
command: deluser --remove-home {{item}}
with_items: "{{users_list}}"
when: users_list is defined
ignore_errors: true

- name: delete all JC's user sudoers files
file:
path: /etc/sudoers.d/{{item}}-jumpcloud
state: absent
with_items: "{{users_list}}"
when: users_list is defined

- name: delete all JC's inviqa sudoers files
file:
path: /etc/sudoers.d/inviqa-*
state: absent

- name: list of residual users
shell: ls /home/
register: home_dirs

- debug: msg="{{ansible_hostname}} - {{home_dirs.stdout}}"
# with_items: "{{home_dirs}}"

...