forked from sanguis/ansible-experiments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpattern-finding.yml
44 lines (42 loc) · 1.32 KB
/
pattern-finding.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
---
# Tests a string finding
# run with `ansible-playbook -c local pattern-finding.yml -v`
- hosts:
- local
handlers:
vars:
url: "http://www.example.com/foo/bar.2.0.zip"
string: "filled with stuff and junk"
repo: "https://github.com/jaguillette/hvd-dh-omeka-theme.git"
roles:
tasks:
- name: extract file name from url
set_fact:
file_name: "{{ url.split('/') | last }}"
- name: print just the file name from a url (broken do to multiple dots)
set_fact:
created_folder: "{{ file_name.split('.') | first }}"
- name: regex replace test
set_fact:
regex_replace: "{{ url | regex_replace('^(.*\\/)(.*)\\..*$', '\\2') }}"
# file uncommenting
- name: copy example file into /tmp to test
synchronize:
src: ./assets/commented-ini.ini
dest: /tmp/commented-ini.ini
delegate_to: "{{ inventory_hostname }}"
- name: uncomment lines
replace:
dest: /tmp/commented-ini.ini
regexp: ; (storage\.adapter( |Options\.(access|secret|bucket)))
replace: \1
# sring fliters
- name: check for git in repo
debug:
msg: its a git repo.
when: repo | search(".git")
- name: check for git in repo
debug:
msg: not a repo this should break
ignore_errors: yes
when: url | search(".git")