This repository has been archived by the owner on Nov 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 184
/
test-rackspace.yml
105 lines (92 loc) · 2.38 KB
/
test-rackspace.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Build a new cloud server
action:
module: rax
credentials: .pyrax
name: "cis-rhel-ansible-testing"
flavor: general1-2
image: aa68fd54-2f9a-42c3-9901-4035e2738830
key_name: travis-key
wait: yes
region: IAD
state: present
networks:
- private
- public
group: raxhosts
register: rax
- name: Add new instance to host group
local_action:
module: add_host
hostname: "{{ item.accessIPv4 }}"
groupname: raxhosts
with_items: rax.instances
- name: Wait for server to come online
hosts: raxhosts
user: root
gather_facts: false
tasks:
- name: Wait for server to come online
wait_for: >
port=22
timeout=300
- name: Test the ansible playbook on the remote host
hosts: raxhosts
user: root
tasks:
# This is mainly to prevent shenanigans with people trying to hop
# into the VM while it's building at travis-ci. ;)
- name: Disable ssh authentication with passwords
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PasswordAuthentication"
line: "PasswordAuthentication no"
- name: Restart sshd
service:
name: sshd
state: restarted
- name: Install ansible
yum:
name: ansible
state: latest
- name: Make a directory to hold the ansible scripts
file:
path: /root/ansible-role-cis/
state: directory
- name: Copy over files
copy:
src: "{{ item }}"
dest: /root/ansible-role-cis/
with_items:
- ansible.cfg
- hosts
- playbook.yml
- roles
- name: Run the ansible playbook
shell: "cd /root/ansible-role-cis && ansible-playbook -i hosts playbook.yml"
- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Delete the cloud server
action:
module: rax
credentials: .pyrax
name: "cis-rhel-ansible-testing"
flavor: general1-2
image: aa68fd54-2f9a-42c3-9901-4035e2738830
key_name: travis-key
wait: yes
region: IAD
state: present
group: raxhosts
count: 0
exact_count: yes
networks:
- private
- public
register: rax