Context : In cold ( T < 25 K ) and dense ( n _ { H } > 10 ^ { 4 } cm ^ { -3 } ) interstellar clouds , molecules like CO are significantly frozen onto dust grain surfaces . Deuterium fractionation is known to be very efficient in these conditions as CO limits the abundance of H _ { 3 } ^ { + } , the starting point of deuterium chemistry . In particular , { N _ { 2 } D ^ { + } } is an excellent tracer of dense and cold gas in star forming regions . Aims : We measure the deuterium fraction , R _ { D } , and the CO-depletion factor , f _ { d } , toward a number of starless and protostellar cores in the L1688 region of the Ophiuchus molecular cloud complex and search for variations based upon environmental differences across L1688 . The kinematic properties of the dense gas traced by the N _ { 2 } H ^ { + } and N _ { 2 } D ^ { + } ( 1–0 ) lines are also discussed . Methods : R _ { D } has been measured via observations of the J = 1–0 transition of N _ { 2 } H ^ { + } and N _ { 2 } D ^ { + } toward 33 dense cores in different regions of L1688 . f _ { d } estimates have been done using C ^ { 17 } O ( 1–0 ) and 850 \mu m dust continuum emission from the SCUBA survey . All line observations were carried out with the IRAM 30 meter antenna . Results : The dense cores show large ( \simeq 2–40 % ) deuterium fractions , with significant variations between the sub-regions of L1688 . The CO-depletion factor also varies from one region to another ( between \simeq 1 and 7 ) . Two different correlations are found between deuterium fraction and CO-depletion factor : cores in regions A , B2 and I show increasing R _ { D } with increasing f _ { d } , similar to previous studies of deuterium fraction in pre-stellar cores ; cores in regions B1 , B1B2 , C , E , F and H show a steeper R _ { D } – f _ { d } correlation , with large deuterium fractions occurring in fairly quiescent gas with relatively low CO freeze-out factors . These are probably recently formed , centrally concentrated starless cores which have not yet started the contraction phase toward protostellar formation . We also find that the deuterium fraction is affected by the amount of turbulence , dust temperature and distance from heating sources in all regions of L1688 , although no clear trend is found . Conclusions : The deuterium fraction and amount of CO freeze-out are sensitive to environmental conditions and their variations across L1688 show that regions of the same molecular cloud experience different dynamical , thermal and chemical histories , with consequences for the current star formation efficiency and the characteristics of future stellar systems . The large pressures present in L1688 may induce the formation of small dense starless cores , unresolved with our beam , where the R _ { D } – f _ { d } relation appears to deviate from that expected from chemical models . We predict that high angular resolution observations will reconcile observations with theory .