Skip to content

Commit cb3facc

Browse files
authored
Merge pull request #200 from cyberark/snyk-fixes
Update Docker Compose Syntax, base images
2 parents 05176c8 + 2a50824 commit cb3facc

7 files changed

Lines changed: 35 additions & 30 deletions

File tree

CONTRIBUTING.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Before getting started, the following tools need to be installed:
3838

3939
## Set up a development environment
4040

41-
The `dev` directory contains a `docker-compose` file which creates a development
41+
The `dev` directory contains a `docker-compose.yml` file which creates a development
4242
environment :
4343
- A Conjur Open Source instance
4444
- An Ansible control node
@@ -142,28 +142,28 @@ Generate the master key, which will be used to encrypt Conjur's database. Store
142142
this value as an environment variable.
143143

144144
```sh-session
145-
docker-compose run --no-deps --rm conjur data-key generate > data_key
145+
docker compose run --no-deps --rm conjur data-key generate > data_key
146146
export CONJUR_DATA_KEY="$(< data_key)"
147147
```
148148

149149
Start the Conjur OSS environment. An account, named `cucumber`, will be
150150
automatically created.
151151

152152
```sh-session
153-
docker-compose up -d conjur
153+
docker compose up -d conjur
154154
```
155155

156156
Retrieve the admin user's API key, and store the value in an environment variable.
157157

158158
```sh-session
159-
export CLI_CONJUR_AUTHN_API_KEY="$(docker-compose exec conjur conjurctl role retrieve-key cucumber:user:admin)"
159+
export CLI_CONJUR_AUTHN_API_KEY="$(docker compose exec conjur conjurctl role retrieve-key cucumber:user:admin)"
160160
```
161161

162162
Start the Conjur CLI container. The CLI will be automatically authenticated as
163163
the user `cucumber:user:admin`.
164164

165165
```sh-session
166-
docker-compose up -d conjur_cli
166+
docker compose up -d conjur_cli
167167
```
168168

169169
## Load policy to set up Conjur Ansible integration
@@ -174,15 +174,15 @@ be a policy, a host, a user, a layer, a group, or a variable.
174174
Check out the policy file, and load it into Conjur:
175175

176176
```sh-session
177-
docker-compose exec conjur_cli cat /policy/root.yml
178-
docker-compose exec conjur_cli conjur policy load root /policy/root.yml
177+
docker compose exec conjur_cli cat /policy/root.yml
178+
docker compose exec conjur_cli conjur policy load root /policy/root.yml
179179
```
180180

181181
Also, load a dummy secret value into the `ansible/target-password` variable.
182182
This is a variable required by remote nodes in order to complete their workloads.
183183

184184
```sh-session
185-
docker-compose exec conjur_cli conjur variable values add ansible/target-password S3cretV@lue
185+
docker compose exec conjur_cli conjur variable values add ansible/target-password S3cretV@lue
186186
```
187187

188188
## Create Ansible managed nodes
@@ -192,15 +192,15 @@ nodes. First, retrieve the API key for the Conjur host representing the control
192192
node, then create it:
193193

194194
```sh-session
195-
export ANSIBLE_CONJUR_AUTHN_API_KEY="$(docker-compose exec conjur conjurctl role retrieve-key cucumber:host:ansible/ansible-master)"
196-
docker-compose up -d ansible
195+
export ANSIBLE_CONJUR_AUTHN_API_KEY="$(docker compose exec conjur conjurctl role retrieve-key cucumber:host:ansible/ansible-master)"
196+
docker compose up -d ansible
197197
```
198198

199199
Next, create two instances of each managed node:
200200

201201
```sh-session
202-
docker-compose up -d --scale test_app_ubuntu=2 test_app_ubuntu
203-
docker-compose up -d --scale test_app_centos=2 test_app_centos
202+
docker compose up -d --scale test_app_ubuntu=2 test_app_ubuntu
203+
docker compose up -d --scale test_app_centos=2 test_app_centos
204204
```
205205

206206
## Use Conjur Ansible Role to set up identity on managed nodes
@@ -209,13 +209,13 @@ To grant your Ansible host a Conjur identity, first install the Conjur
209209
Collection on your Ansible control node:
210210

211211
```sh-session
212-
docker-compose exec ansible ansible-galaxy collection install cyberark.conjur
212+
docker compose exec ansible ansible-galaxy collection install cyberark.conjur
213213
```
214214

215215
Set up the host factory token in the HFTOKEN env var
216216

217217
```sh-session
218-
export HFTOKEN="$(docker-compose exec conjur_cli conjur hostfactory tokens create ansible/ansible-factory | jq -r '.[0].token')"
218+
export HFTOKEN="$(docker compose exec conjur_cli conjur hostfactory tokens create ansible/ansible-factory | jq -r '.[0].token')"
219219
```
220220

221221
Once you've done this, you can configure each Ansible node with a Conjur

dev/start.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ function deploy_conjur_open_source() {
6969
echo "---- deploying Conur Open Source ----"
7070

7171
# start conjur server
72-
docker-compose up -d --build conjur conjur-proxy-nginx
73-
set_conjur_cid "$(docker-compose ps -q conjur)"
72+
docker compose up -d --build conjur conjur-proxy-nginx
73+
set_conjur_cid "$(docker compose ps -q conjur)"
7474
wait_for_conjur
7575

7676
# get admin credentials
77-
fetch_conjur_cert "$(docker-compose ps -q conjur-proxy-nginx)" "cert.crt"
77+
fetch_conjur_cert "$(docker compose ps -q conjur-proxy-nginx)" "cert.crt"
7878
ADMIN_API_KEY="$(user_api_key "$CONJUR_ACCOUNT" admin)"
7979

8080
# start conjur cli and configure conjur
81-
docker-compose up --no-deps -d conjur_cli
82-
set_cli_cid "$(docker-compose ps -q conjur_cli)"
81+
docker compose up --no-deps -d conjur_cli
82+
set_cli_cid "$(docker compose ps -q conjur_cli)"
8383
setup_conjur_resources
8484
}
8585

@@ -92,12 +92,12 @@ function deploy_conjur_enterprise {
9292
# start conjur leader and follower
9393
./bin/dap --provision-master
9494
./bin/dap --provision-follower
95-
set_conjur_cid "$(docker-compose ps -q conjur-master.mycompany.local)"
95+
set_conjur_cid "$(docker compose ps -q conjur-master.mycompany.local)"
9696

9797
fetch_conjur_cert "$(conjur_cid)" "/etc/ssl/certs/ca.pem"
9898

9999
# Run 'sleep infinity' in the CLI container so it stays alive
100-
set_cli_cid "$(docker-compose run --no-deps -d -w /src/cli --entrypoint sleep client infinity)"
100+
set_cli_cid "$(docker compose run --no-deps -d -w /src/cli --entrypoint sleep client infinity)"
101101
# Authenticate the CLI container
102102
docker exec "$(cli_cid)" /bin/sh -c "
103103
if [ ! -e /root/conjur-demo.pem ]; then
@@ -142,8 +142,8 @@ function main() {
142142
refresh_access_token "host/ansible/ansible-master" "$ANSIBLE_API_KEY"
143143

144144
# start ansible control node
145-
docker-compose up -d --build ansible
146-
set_ansible_cid "$(docker-compose ps -q ansible)"
145+
docker compose up -d --build ansible
146+
set_ansible_cid "$(docker compose ps -q ansible)"
147147

148148
# scale ansible managed nodes
149149
generate_inventory

dev/stop.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ declare -x DOCKER_NETWORK='default'
77
echo "---- removing dev environment----"
88
cd "$(dev_dir)"
99

10-
docker-compose down -v
10+
docker compose down -v
1111

1212
if [[ -n "$(cli_cid)" ]]; then
1313
docker rm -f "$(cli_cid)"

dev/test_app_centos/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
FROM centos:7
1+
FROM centos:latest
2+
3+
#
4+
RUN cd /etc/yum.repos.d/
5+
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
6+
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
27

38
# Install Python so Ansible can run against node
49
RUN yum update -y && yum install -y python3

dev/test_app_ubuntu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04
1+
FROM ubuntu:22.04
22

33
# Install Python so Ansible can run against node
44
RUN apt-get update -y && apt-get install -y python3-minimal

dev/util.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function dev_dir {
1010
}
1111

1212
function compose_major_version {
13-
docker-compose version --short | cut -d "." -f 1
13+
docker compose version --short | cut -d "." -f 1
1414
}
1515

1616
function set_network {
@@ -91,8 +91,8 @@ function teardown_and_setup_inventory {
9191
pushd "$(dev_dir)"
9292
# shellcheck disable=SC2155
9393
export DOCKER_NETWORK="$(network)"
94-
docker-compose up -d --force-recreate --scale test_app_ubuntu=2 test_app_ubuntu
95-
docker-compose up -d --force-recreate --scale test_app_centos=2 test_app_centos
94+
docker compose up -d --force-recreate --scale test_app_ubuntu=2 test_app_ubuntu
95+
docker compose up -d --force-recreate --scale test_app_centos=2 test_app_centos
9696
popd
9797
}
9898

0 commit comments

Comments
 (0)