replica_tasks.yml #2

  • //
  • guest/
  • perforce_software/
  • sdp/
  • dev/
  • test/
  • replica_tasks.yml
  • View
  • Commits
  • Open Download .zip Download (2 KB)
# replica_tasks.yml
# Included from install_sdp.yml
# Parameters:
#   server_type
#   server_id

---

- name: Update variables in config file
  lineinfile:
    dest: /hxdepots/sdp/Server/Unix/setup/mkdirs.cfg
    regexp: "{{item.regexp}}"
    line: "{{item.line}}"
  with_items:
    - {regexp: '^SSL_PREFIX=', line: 'SSL_PREFIX='}
    - {regexp: '^P4HOSTNAME=', line: 'P4HOSTNAME=master'}
    - {regexp: '^SERVER_TYPE=', line: 'SERVER_TYPE={{server_type}}'}
    - {regexp: '^REPLICA_ID=', line: 'REPLICA_ID={{server_id}}'}

- name: Execute replica mkdirs (as root)
  shell: cd /hxdepots/sdp/Server/Unix/setup && ./mkdirs.sh 1
  become: yes

- name: copy checkpoints to replica
  synchronize:
    src: /p4/1/checkpoints/
    dest: /p4/1/checkpoints/

- name: copy admin password file to replica
  copy:
    src: /p4/common/config/.p4passwd.p4_1.admin
    dest: /p4/common/config/.p4passwd.p4_1.admin

- name: copy mkrep logs to replica
  synchronize:
    src: "{{item}}"
    dest: /p4/1/logs/
  with_lines: "find /p4/1/logs/ -name mkrep*.log"

- name: Record name of mkrep log for this server
  shell: grep "p4 server {{server_id}}" /p4/1/logs/mkrep* | tail -1 | sed -e 's/:.*//'
  register: mkrep_log

- name: Record latest checkpoint file
  shell: ls -tr /p4/1/checkpoints/*.ckp.*.gz | tail -1
  register: ckp_file

- name: STEP 8 Create server id
  shell: "echo {{server_id}} > /p4/1/root/server.id"

- name: STEP 8.1 Create offline server id
  shell: "echo {{server_id}} > /p4/1/offline_db/server.id"

- name: STEP 11 Login the admin user to the master
  shell: "source /p4/common/bin/p4_vars 1 && /p4/1/bin/p4_1 -p master:1667 login < /p4/common/config/.p4passwd.p4_1.admin"

- name: STEP 11.1 Login the service user to the master
  shell: "source /p4/common/bin/p4_vars 1 && /p4/1/bin/p4_1 -p master:1667 login svc_{{server_id}}"

- name: STEP 12 Create db files/load checkpoint
  shell: "/p4/common/bin/load_checkpoint.sh -i 1 -y -l {{ ckp_file.stdout_lines[0] }}"

- name: STEP 12.1 Create offline_db files
  shell: "/p4/1/bin/p4d_1 -r /p4/1/offline_db -z -jr {{ ckp_file.stdout_lines[0] }}"

- name: STEP 12.2 Mark the Offline_db as usable
  shell: "echo Usable > /p4/1/offline_db/offline_db_usable.txt"

- name: STEP 13. Start the replica
  shell: "/p4/1/bin/p4d_1_init start"
# Change User Description Committed
#2 26782 Robert Cowham Update tests of multiple replicas vis docker compose for mkrep.sh/ansible/loacheckpoint.sh
Pre-cursor to turning on these tests as part of CI
#1 25566 Robert Cowham Refactored ansible to include sub tasks for each replica