11version : ' 3'
22
33vars :
4- ARTIFACT_DIR : " {{.PWD}}/artifacts"
5- ANSIBLE_COLLECTIONS_PATH : " {{.ARTIFACT_DIR}}/collections"
6- ANSIBLE_ROLES_PATH : " {{.ARTIFACT_DIR}}/roles"
7- MAC_RPK : " https://github.com/redpanda-data/redpanda/releases/latest/download/rpk-darwin-amd64.zip"
8- LINUX_RPK : " https://github.com/redpanda-data/redpanda/releases/latest/download/rpk-linux-amd64.zip"
9- SSH_EMAIL :
' {{.SSH_EMAIL | default "[email protected] "}}' 104 CLIENT_NAME : ' {{.CLIENT_NAME | default "client"}}'
11- CLIENT_DIR : " {{.PWD }}/ansible/tls/clients"
12- CA_DIR : " {{.PWD }}/ansible/tls/ca"
13- CERT_DIR : " {{.PWD }}/ansible/tls/certs"
5+ CLIENT_DIR : " {{.ROOT_DIR }}/ansible/tls/clients"
6+ CA_DIR : " {{.ROOT_DIR }}/ansible/tls/ca"
7+ CERT_DIR : " {{.ROOT_DIR }}/ansible/tls/certs"
148
159tasks :
1610 default :
@@ -30,23 +24,32 @@ tasks:
3024 _ansible-collections :
3125 internal : true
3226 desc : " Install Ansible collections from requirements.yml"
27+ sources :
28+ - " {{.ROOT_DIR}}/requirements.yml"
29+ generates :
30+ - " {{.ANSIBLE_COLLECTIONS_PATH}}/ansible_collections"
3331 cmds :
3432 - mkdir -p {{.ANSIBLE_COLLECTIONS_PATH}}
35- - ansible-galaxy collection install -r {{.PWD}}/requirements.yml --force -p {{.ANSIBLE_COLLECTIONS_PATH}}
36- status :
37- - test -d {{.ANSIBLE_COLLECTIONS_PATH}}/ansible_collections
33+ - ansible-galaxy collection install -r {{.ROOT_DIR}}/requirements.yml --force -p {{.ANSIBLE_COLLECTIONS_PATH}}
3834
3935 _ansible-roles :
4036 internal : true
4137 desc : " Install Ansible roles from requirements.yml"
38+ sources :
39+ - " {{.ROOT_DIR}}/requirements.yml"
40+ generates :
41+ - " {{.ANSIBLE_ROLES_PATH}}"
4242 cmds :
4343 - mkdir -p {{.ANSIBLE_ROLES_PATH}}
44- - ansible-galaxy role install -r {{.PWD}}/requirements.yml --force -p {{.ANSIBLE_ROLES_PATH}}
45- status :
46- - test -d {{.ANSIBLE_ROLES_PATH}}
44+ - ansible-galaxy role install -r {{.ROOT_DIR}}/requirements.yml --force -p {{.ANSIBLE_ROLES_PATH}}
4745
4846 rpk :
4947 desc : " Install rpk CLI tool"
48+ vars :
49+ MAC_RPK : " https://github.com/redpanda-data/redpanda/releases/latest/download/rpk-darwin-amd64.zip"
50+ LINUX_RPK : " https://github.com/redpanda-data/redpanda/releases/latest/download/rpk-linux-amd64.zip"
51+ generates :
52+ - " {{.ARTIFACT_DIR}}/bin/rpk"
5053 cmds :
5154 - mkdir -p {{.ARTIFACT_DIR}}/tmp
5255 - mkdir -p {{.ARTIFACT_DIR}}/bin
@@ -61,21 +64,17 @@ tasks:
6164 - chmod 755 {{.ARTIFACT_DIR}}/bin/rpk
6265 - rm {{.ARTIFACT_DIR}}/tmp/rpk.zip
6366 - echo "rpk installed to {{.ARTIFACT_DIR}}/bin/rpk"
64- status :
65- - test -f {{.ARTIFACT_DIR}}/bin/rpk
6667
6768 ssh-keys :
6869 desc : " Generate SSH keypair for deployment"
70+ vars :
71+ SSH_EMAIL :
' {{.SSH_EMAIL | default "[email protected] "}}' 72+ generates :
73+ - " {{.ARTIFACT_DIR}}/testkey"
74+ - " {{.ARTIFACT_DIR}}/testkey.pub"
6975 cmds :
70- - |
71- if [ ! -f artifacts/testkey ]; then
72- printf 'y\n' | ssh-keygen -t rsa -b 4096 -C "{{.SSH_EMAIL}}" -N "" -f artifacts/testkey && chmod 0700 artifacts/testkey
73- echo "SSH keypair generated"
74- else
75- echo "SSH keypair already exists"
76- fi
77- status :
78- - test -f artifacts/testkey
76+ - printf 'y\n' | ssh-keygen -t rsa -b 4096 -C "{{.SSH_EMAIL}}" -N "" -f {{.ARTIFACT_DIR}}/testkey && chmod 0700 {{.ARTIFACT_DIR}}/testkey
77+ - echo "SSH keypair generated"
7978
8079 tls-certs :
8180 desc : " Generate client TLS certificates"
@@ -88,31 +87,37 @@ tasks:
8887
8988 _cert-client-dir :
9089 internal : true
90+ generates :
91+ - " {{.CLIENT_DIR}}"
9192 cmds :
9293 - mkdir -p {{.CLIENT_DIR}}
93- status :
94- - test -d {{.CLIENT_DIR}}
9594
9695 _cert-client-key :
9796 internal : true
97+ generates :
98+ - " {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.key"
9899 cmds :
99100 - openssl genrsa -out {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.key 2048
100- status :
101- - test -f {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.key
102101
103102 _cert-client-csr :
104103 internal : true
104+ sources :
105+ - " {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.key"
106+ generates :
107+ - " {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.csr"
105108 cmds :
106109 - openssl req -new -key {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.key -out {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.csr -subj "/CN={{.CLIENT_NAME}}"
107- status :
108- - test -f {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.csr
109110
110111 _cert-client-crt :
111112 internal : true
113+ sources :
114+ - " {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.csr"
115+ - " {{.CA_DIR}}/ca.crt"
116+ - " {{.CA_DIR}}/ca.key"
117+ generates :
118+ - " {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.crt"
112119 cmds :
113120 - openssl x509 -req -in {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.csr -CA {{.CA_DIR}}/ca.crt -CAkey {{.CA_DIR}}/ca.key -CAcreateserial -out {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.crt -days 365 -sha256
114- status :
115- - test -f {{.CLIENT_DIR}}/{{.CLIENT_NAME}}.crt
116121
117122 clean-certs :
118123 desc : " Remove all TLS certificates"
0 commit comments